Skip to content

Commit

Permalink
Use stable hash for binding arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg committed Jul 28, 2024
1 parent 2efb566 commit 12f73a2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lavinmq/vhost.cr
Original file line number Diff line number Diff line change
Expand Up @@ -673,25 +673,29 @@ module LavinMQ
when AMQP::Frame::Exchange::Delete
@etcd.del(join_path("lavinmq", @name, "exchanges", f.exchange_name))
when AMQP::Frame::Exchange::Bind
@etcd.put(join_path("lavinmq", @name, "exchange", f.destination, "bindings", f.source, f.routing_key, f.arguments.hash),
args_hash = f.arguments.hash(Crystal::Hasher.new(0, 0)).result
@etcd.put(join_path("lavinmq", @name, "exchange", f.destination, "bindings", f.source, f.routing_key, args_hash),
{
arguments: f.arguments,
}.to_json)
when AMQP::Frame::Exchange::Unbind
@etcd.del(join_path("lavinmq", @name, "exchange", f.destination, "bindings", f.source, f.routing_key, f.arguments.hash))
args_hash = f.arguments.hash(Crystal::Hasher.new(0, 0)).result
@etcd.del(join_path("lavinmq", @name, "exchange", f.destination, "bindings", f.source, f.routing_key, args_hash))
when AMQP::Frame::Queue::Declare
@etcd.put(join_path("lavinmq", @name, "queues", f.queue_name), {
arguments: f.arguments,
}.to_json)
when AMQP::Frame::Queue::Delete
@etcd.del(join_path("lavinmq", @name, "queues", f.queue_name))
when AMQP::Frame::Queue::Bind
@etcd.put(join_path("lavinmq", @name, "queues", f.queue_name, "bindings", f.exchange_name, f.routing_key, f.arguments.hash),
args_hash = f.arguments.hash(Crystal::Hasher.new(0, 0)).result
@etcd.put(join_path("lavinmq", @name, "queues", f.queue_name, "bindings", f.exchange_name, f.routing_key, args_hash),
{
arguments: f.arguments,
}.to_json)
when AMQP::Frame::Queue::Unbind
@etcd.put(join_path("lavinmq", @name, "queues", f.queue_name, "bindings", f.exchange_name, f.routing_key, f.arguments.hash))
args_hash = f.arguments.hash(Crystal::Hasher.new(0, 0)).result
@etcd.del(join_path("lavinmq", @name, "queues", f.queue_name, "bindings", f.exchange_name, f.routing_key, args_hash))
else raise "Cannot apply frame #{f.class} in vhost #{@name}"
end
end
Expand Down

0 comments on commit 12f73a2

Please sign in to comment.