From 787840d8d0aa0a30ddcff4598927f4f33c6201d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=C3=B6rjesson?= Date: Wed, 25 Sep 2024 15:43:59 +0200 Subject: [PATCH] Change QueueBinding from Tuple to struct --- src/lavinmq/http/controller/queues.cr | 4 +++- src/lavinmq/vhost.cr | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lavinmq/http/controller/queues.cr b/src/lavinmq/http/controller/queues.cr index 35f02742b0..fc2a75f037 100644 --- a/src/lavinmq/http/controller/queues.cr +++ b/src/lavinmq/http/controller/queues.cr @@ -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 diff --git a/src/lavinmq/vhost.cr b/src/lavinmq/vhost.cr index b5fd078906..63811fd32c 100644 --- a/src/lavinmq/vhost.cr +++ b/src/lavinmq/vhost.cr @@ -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