Skip to content

Commit

Permalink
fix jobs names type
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon committed Oct 16, 2024
1 parent 89d46dd commit 55712dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/umbrellio_utils/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def capsules_for(worker, max_concurrency)
weight_coef = capsule.weight / total_weight.to_f
concurrency = (max_concurrency * weight_coef).to_i
concurrency = 1 unless concurrency > 1
queues = self.queues.select { |x| x.capsule == capsule.name }.map { |x| [x.name, x.weight] }
queues =
self.queues.select { |x| x.capsule == capsule.name }.map { |x| [x.name.to_s, x.weight] }
Entry.new(capsule.name, queues, concurrency)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/umbrellio_utils/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module UmbrellioUtils
VERSION = "1.5.0"
VERSION = "1.5.1"
end
16 changes: 8 additions & 8 deletions spec/umbrellio_utils/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
specify do
expect(result).to eq(
[
UmbrellioUtils::Jobs::Entry.new(:default, [[:q3, 10], [:q4, 1]], 1),
UmbrellioUtils::Jobs::Entry.new(:cap1, [[:q1, 1]], 3),
UmbrellioUtils::Jobs::Entry.new(:cap2, [[:q2, 5]], 6),
UmbrellioUtils::Jobs::Entry.new(:default, [["q3", 10], ["q4", 1]], 1),
UmbrellioUtils::Jobs::Entry.new(:cap1, [["q1", 1]], 3),
UmbrellioUtils::Jobs::Entry.new(:cap2, [["q2", 5]], 6),
],
)
end
Expand All @@ -49,7 +49,7 @@
specify do
expect(result).to eq(
[
UmbrellioUtils::Jobs::Entry.new(:cap3, [[:q5, 1]], 10),
UmbrellioUtils::Jobs::Entry.new(:cap3, [["q5", 1]], 10),
],
)
end
Expand Down Expand Up @@ -80,21 +80,21 @@
specify do
jobs.configure_capsules!(config, priority_level: "default", max_concurrency: 10)

expect(capsule_default.queues).to eq([[:q3, 10], [:q4, 1]])
expect(capsule_default.queues).to eq([["q3", 10], ["q4", 1]])
expect(capsule_default.concurrency).to eq(1)

expect(capsule_cap1.queues).to eq([[:q1, 1]])
expect(capsule_cap1.queues).to eq([["q1", 1]])
expect(capsule_cap1.concurrency).to eq(3)

expect(capsule_cap2.queues).to eq([[:q2, 5]])
expect(capsule_cap2.queues).to eq([["q2", 5]])
expect(capsule_cap2.concurrency).to eq(6)
end

context "non default level" do
specify do
jobs.configure_capsules!(config, priority_level: "w1", max_concurrency: 10)

expect(capsule_default.queues).to eq([[:q5, 1]])
expect(capsule_default.queues).to eq([["q5", 1]])
expect(capsule_default.concurrency).to eq(10)

expect(capsule_cap1.queues).to eq(nil)
Expand Down

0 comments on commit 55712dd

Please sign in to comment.