Skip to content

Commit

Permalink
always include default binding for queue bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
snichme committed Sep 27, 2024
1 parent 8194749 commit f376f8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions spec/upstream_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,18 @@ describe LavinMQ::Federation::Upstream do
wait_for { upstream.links.first?.try &.state.running? }

upstream_q = upstream_vhost.queues.values.first
upstream_q.bindings.size.should eq queues.size
upstream_q.bindings.size.should eq queues.size + 1 # +1 for the default exchange
# Assert setup is correct
10.times do |i|
downstream_q = downstream_ch.queue("")
downstream_q.bind("downstream_ex", "after.link.#{i}")
queues << downstream_q
end
sleep 0.1.seconds
upstream_q.bindings.size.should eq queues.size
upstream_q.bindings.size.should eq queues.size + 1
queues.each &.delete
sleep 10.milliseconds
upstream_q.bindings.size.should eq 0
upstream_q.bindings.size.should eq 1
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions src/lavinmq/http/controller/queues.cr
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ module LavinMQ
with_vhost(context, params) do |vhost|
refuse_unless_management(context, user(context), vhost)
queue = queue(context, params, vhost)
itr = queue.bindings # .map { |exchange, args| BindingDetails.new(exchange.name, vhost, args[0], args[1], queue) }
# default_binding = BindingDetails.new("", queue.vhost.name, queue.name, nil, queue)
page(context, itr) # {default_binding}.each.chain(itr))
page(context, queue.bindings)
end
end

Expand Down
3 changes: 2 additions & 1 deletion src/lavinmq/vhost.cr
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ module LavinMQ
end

def queue_bindings(queue : Queue) : Iterator(BindingDetails)
default_binding = BindingDetails.new("", name, BindingKey.new(queue.name), queue)
@exchanges.each_value.flat_map do |ex|
ex.bindings_details.select { |binding| binding.destination == queue }
end
end.chain({default_binding}.each)
end

def add_operator_policy(name : String, pattern : String, apply_to : String,
Expand Down

0 comments on commit f376f8a

Please sign in to comment.