Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to exchange #786

Merged
merged 5 commits into from
Oct 14, 2024
Merged

Publish to exchange #786

merged 5 commits into from
Oct 14, 2024

Conversation

snichme
Copy link
Member

@snichme snichme commented Sep 18, 2024

WHAT is this pull request doing?

Move the logic of publishing a message to an exchange from Vhost to the exchange.

The idea came because of the need for the exchange to handle the messages differently for MQTT support
but it has additional benefits like @queue_bindings and @exchange_bindings can have different types and as you may see I've used only one "bindings" for both queue and exchange. for example for FanoutExchange it's just a @bindings : Set(Destination)

There is probably some more things that should move down to each subclass to make the code clearer and to support the different types that @bindings has now.

HOW can this pull request be tested?

specs

spec/tx_spec.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/default.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/default.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/default.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/direct.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Show resolved Hide resolved
This was referenced Sep 25, 2024
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/topic.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/topic.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/topic.cr Outdated Show resolved Hide resolved
@snichme
Copy link
Member Author

snichme commented Sep 27, 2024

@spuun @carlhoerberg any thoughts about always including "default" exchange when getting bindings for a queue heere: https://github.com/cloudamqp/lavinmq/blob/publish-to-exchange/src/lavinmq/vhost.cr#L286
instead of adding the default in the http controllers

@carlhoerberg
Copy link
Member

Im fine with that

@snichme snichme marked this pull request as ready for review September 27, 2024 14:54
Copy link
Member

@spuun spuun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of stamina to suggest a few other early returns... I'm not gonna fight for early returns, but i think it's nice.

src/lavinmq/exchange/consistent_hash.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/consistent_hash.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/consistent_hash.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/default.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/default.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/topic.cr Outdated Show resolved Hide resolved
@snichme
Copy link
Member Author

snichme commented Sep 30, 2024

@spuun agree, early return is nicer. Fixed all now I thinkg

src/lavinmq/exchange.cr Outdated Show resolved Hide resolved
@snichme
Copy link
Member Author

snichme commented Oct 8, 2024

Specs fails because of this: cloudamqp/amqp-client.cr#48

@snichme snichme force-pushed the publish-to-exchange branch 2 times, most recently from 2f9392c to c107036 Compare October 9, 2024 11:31
Copy link
Member

@kickster97 kickster97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has been working well in the mqtt branch!

src/lavinmq/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/headers.cr Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
src/lavinmq/exchange/exchange.cr Outdated Show resolved Hide resolved
Comment on lines 193 to 197
when Queue
queues.add(d) unless d.closed?
when Exchange
d.find_queues(routing_key, headers, queues, exchanges)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
when Queue
queues.add(d) unless d.closed?
when Exchange
d.find_queues(routing_key, headers, queues, exchanges)
end
in Queue
queues.add(d) unless d.closed?
in Exchange
d.find_queues(routing_key, headers, queues, exchanges)
end

@snichme snichme requested a review from a team as a code owner October 14, 2024 07:18
@snichme snichme merged commit 02e9aab into main Oct 14, 2024
25 checks passed
@snichme snichme deleted the publish-to-exchange branch October 14, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants