Skip to content

Commit

Permalink
Change QueueBinding from Tuple to struct
Browse files Browse the repository at this point in the history
  • Loading branch information
spuun authored and kickster97 committed Sep 25, 2024
1 parent 7d460e9 commit 787840d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/lavinmq/http/controller/queues.cr
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ 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, queue) }
itr = queue.bindings.map do |binding|
BindingDetails.new(binding.exchange.name, vhost, binding.binding_key, queue)
end
default_binding = BindingDetails.new("", queue.vhost.name, BindingKey.new(queue.name, nil), queue)
page(context, {default_binding}.each.chain(itr))
end
Expand Down
4 changes: 2 additions & 2 deletions src/lavinmq/vhost.cr
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ module LavinMQ
end
end

alias QueueBinding = Tuple(BindingKey, Exchange)
record QueueBinding, binding_key : BindingKey, exchange : Exchange

def queue_bindings(queue : Queue)
iterators = @exchanges.each_value.map do |ex|
ex.queue_bindings.each.select do |(_binding_args, destinations)|
destinations.includes?(queue)
end.map { |(binding_args, _destinations)| {ex, binding_args} }
end.map { |(binding_key, _destinations)| QueueBinding.new(binding_key, ex) }
end
Iterator(QueueBinding).chain(iterators)
end
Expand Down

0 comments on commit 787840d

Please sign in to comment.