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

Control naming of events #239

Open
SemanticBeeng opened this issue Jun 17, 2019 · 1 comment
Open

Control naming of events #239

SemanticBeeng opened this issue Jun 17, 2019 · 1 comment

Comments

@SemanticBeeng
Copy link

SemanticBeeng commented Jun 17, 2019

Interested to have the ability to name events explicitly instead of the name assumed to be the Class.getSimpleName.

This would improve the communication through visual representation of recipes by naming events to include bounded contexts (context of Domain Driven Design).

Area of code clearly related:

https://github.com/SemanticBeeng/baker/blob/53504b24ae22a9b0084281b9dd517f2a86e843cc/runtime/src/main/scala/com/ing/baker/runtime/core/Baker.scala#L43-L49

Thinking to introduce a configurable EventNameExtractor mechanism.
Of of the possible implementations would be look for def name or val name in the class.

Would you welcome this?

@Tim-Linschoten
Copy link
Member

Naming events explicitly is something we have looked into and its nice to know your requirement.
In Baker release 3 this will be possible for you to do.
Instead of firing any Object into Baker you always send in a RuntimeEvent into Baker.
We then provide you a helper function to go from any Object to a RuntimeEvent.
This is a little more verbose but simplifies Baker in general in our opinion.

Here is some example code (all names are still pending).

baker.fireSensoryEvent(processId,
                    RuntimeEvent.from(new SensoryEventToFire()))

Since you now fire a RuntimeEvent into Baker you are free to create a RuntimeEvent yourself.
For example now you can:

RuntimeEvent runtimeEvent = new RuntimeEvent("domain.SensoryEventToFire");

baker.fireSensoryEventReceived(processId, runtimeEvent );

or

RuntimeEvent runtimeEvent = RuntimeEvent.from(SensoryEventToFire.class)
     .copy("domain.SensoryEventToFire");

baker.fireSensoryEventReceived(processId, runtimeEvent );

You are then also free to create your own helper functions to create RuntimeEvents the way you described it.

Please let me know what you think of this.

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

No branches or pull requests

2 participants