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

Event bus internal improvements #4824

Merged
merged 9 commits into from
Oct 5, 2023
Merged

Conversation

vietj
Copy link
Member

@vietj vietj commented Aug 29, 2023

See also #4712

Decouple message emission from the interceptor chain

EventBus streaming requires to send messages that does not go through the interceptor chain, e.g. establishing a stream requires to send such messages. The sendOrPub method and the downstream chain of calls (sendLocally, sendOrPublishFailed, sendToNode, sendToNodes) are coupled to OutboundDeliveryContext by convenience. The EventBus#sendOrPub is refactored to carry the messages and the delivery options instead of the OutboundDeliveryContext.

Main changes

  • EventBusImpl#sendOrPub(OutboundDeliveryContext) -> EventBusimpl#sendOrPub(ContextInternal,MessageImpl,DeliveryOptions,Promise)
  • same for sendLocally, sendOrPublishFailed, sendToNode, sendToNodes

Decouple the RegistrationHandler from the repliedAddress knowledge

The clustered event bus is aware of the nature of the HandlerHolder: when a HandlerHolder is registered it does broadcast the registration when the HandlerHolder is a reply handler. The HandlerHolder#isReplyHandler() method is removed, instead EventBusImpl#addRegistration replaces the replyHandler boolean by a broadcast boolean, when broadcast is set to false the onLocalRegistration method is not called avoiding the clustered event bus to perform the check.

Main changes:

  • HandlerRegistration#register(String repliedAddress, boolean localOnly, Promise<Void> promise) -> HandlerRegistration#register(boolean broadcast, boolean localOnly, Promise<Void> promise)
  • HandlerHolder does not carry anymore the replyHandler boolean
  • MessageConsumerImpl calls register with broadcast = true
  • ReplyHandler calls register with broadcast = false
  • ClusteredEventBus processes a local registration whatsoever as it is not called for reply handlers

NodeSelector cleanup

The NodeSelector SPI is coupled to event-bus message API, instead it should only care about the message address, this simplifies the API and decouple the NodeSelector SPI from the message.

Main changes:

  • NodeSelector#selectForSend(Message, Promise<String>) -> NodeSelector#selectForSend(String, Promise<String>)
  • etc...

@vietj
Copy link
Member Author

vietj commented Aug 30, 2023

cc @tsegismont , some cleanup required in the PR, just you get the idea of the changes

@tsegismont
Copy link
Contributor

The NodeSelector SPI is coupled to event-bus message API,

It was designed like this so that users can create their own node selector and choose a server depending on metadata provided by messager headers (e..g. implementing sharing on the event bus)

Copy link
Contributor

@tsegismont tsegismont left a comment

Choose a reason for hiding this comment

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

Thanks @vietj

@vietj vietj force-pushed the event-bus-internal-improvements branch from 6132003 to eb6744a Compare October 5, 2023 12:26
@vietj vietj force-pushed the event-bus-internal-improvements branch from eb6744a to 365c383 Compare October 5, 2023 12:32
@vietj vietj marked this pull request as ready for review October 5, 2023 12:33
@vietj vietj added this to the 5.0.0 milestone Oct 5, 2023
@vietj vietj merged commit f0ae90f into master Oct 5, 2023
7 checks passed
@vietj vietj deleted the event-bus-internal-improvements branch October 5, 2023 12:52
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.

None yet

2 participants