Skip to content

Commit

Permalink
Capsule default weights (#5765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exterm1nate committed Feb 4, 2023
1 parent a754dc7 commit 4c47742
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sidekiq/capsule.rb
Expand Up @@ -28,6 +28,7 @@ def initialize(name, config)
@name = name
@config = config
@queues = ["default"]
@weights = { "default" => 0 }
@concurrency = config[:concurrency]
@mode = :strict
end
Expand Down
15 changes: 15 additions & 0 deletions test/capsule_test.rb
Expand Up @@ -43,6 +43,21 @@
assert_equal %w[foo baz baz baz], cap.queues
end

it "parses weights correctly" do
cap = @cap
assert_equal({ "default" => 0 }, cap.weights)

cap.queues = %w[foo bar,2]
assert_equal({ "foo" => 0, "bar" => 2 }, cap.weights)

cap.queues = ["default"]
assert_equal({ "default" => 0 }, cap.weights)

# config/sidekiq.yml input will look like this
cap.queues = [["foo"], ["baz", 3]]
assert_equal({ "foo" => 0, "baz" => 3 }, cap.weights)
end

it "can have customized middleware chains" do
one = Object.new
two = Object.new
Expand Down

0 comments on commit 4c47742

Please sign in to comment.