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

Add sepia routing keys to eiffellib #37

Merged
merged 2 commits into from
Oct 1, 2021

Conversation

t-persson
Copy link
Collaborator

@t-persson t-persson commented Sep 28, 2021

Applicable Issues

fixes: #36

Description of the Change

Add a routing_key property for events.
Deprecate the routing_key argument for RabbitMQPublisher

Alternate Designs

We could also add the routing key arguments to the "send_event" method in the RabbitMQPublisher instead, however I felt like this was something that the events should handle.

Benefits

We would follow sepia and allow for more fine grained control of what to receive in Subscribers.

Possible Drawbacks

This is, potentially, a breaking change for some people

Sign-off

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

Signed-off-by: Tobias Persson [email protected]

Add a routing_key property for events.
Deprecate the routing_key argument for RabbitMQPublisher
@t-persson t-persson requested a review from a team as a code owner September 28, 2021 10:42
@t-persson t-persson requested review from fredjn and magnusbaeck and removed request for a team September 28, 2021 10:42
if version is not None:
self.version = version
self.family = family
self.tag = tag
self.domain_id = domain_id
Copy link
Member

Choose a reason for hiding this comment

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

Should this also affect meta.source.domainId?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know.. Should we also add meta.source.domainId to this automatically in that case?
Do we want implicit behavior?

Copy link
Member

Choose a reason for hiding this comment

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

Implicit isn't bad if documented :-) I'd say that meta.source.domainId and the domain token in the routing key should match each other in the normal case. As a library user I'd be annoyed if I'd have to pass the domain in the constructor but also modify the meta object by hand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will now add event.domain_id to meta.source.domainId if it's set.
It will also add RabbitMQPublisher.source.domainId to event.domain_id if event.domain_id is the default value of "_".

I.e. event.domain_id will always take precedence over RabbitMQPublisher.source.domainId if set

Comment on lines +153 to +161
This method will set the source on all events if there is a source
added to the :obj:`RabbitMQPublisher`.
If the routing key is set to None in the :obj:`RabbitMQPublisher` this
method will use the routing key from the event that is being sent.
The event domainId will also be added to `meta.source` if it is set to
anything other than the default value. If there is no domainId
set on the event, then the domainId from the source in the
:obj:`RabbitMQPublisher` will be used in the routing key, with a default
value taken from the :obj:`eiffellib.events.eiffel_base_event.EiffelBaseEvent`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please help me with this documentation. I am not sure if this is clear enough.

Copy link
Member

Choose a reason for hiding this comment

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

I think the description is clear, but the interface is pretty complicated. Maybe we're giving people too much rope with a source attribute in the publisher, but I'm sure it's convenient since the source is typically the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use that part heavily in ETOS, so it would have a big impact to remove it.
We could of course deprecate it and rework ETOS to add it to all events ETOS publishes, but I kind of like having it here.

Comment on lines +153 to +161
This method will set the source on all events if there is a source
added to the :obj:`RabbitMQPublisher`.
If the routing key is set to None in the :obj:`RabbitMQPublisher` this
method will use the routing key from the event that is being sent.
The event domainId will also be added to `meta.source` if it is set to
anything other than the default value. If there is no domainId
set on the event, then the domainId from the source in the
:obj:`RabbitMQPublisher` will be used in the routing key, with a default
value taken from the :obj:`eiffellib.events.eiffel_base_event.EiffelBaseEvent`.
Copy link
Member

Choose a reason for hiding this comment

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

I think the description is clear, but the interface is pretty complicated. Maybe we're giving people too much rope with a source attribute in the publisher, but I'm sure it's convenient since the source is typically the same.

@t-persson t-persson merged commit 7b032e7 into eiffel-community:main Oct 1, 2021
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.

Routing key for published events should follow Sepia recommendation
3 participants