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

Fix: Supply another mechanism for event naming #907

Open
rasmus opened this issue Oct 20, 2021 · 5 comments · May be fixed by #1062
Open

Fix: Supply another mechanism for event naming #907

rasmus opened this issue Oct 20, 2021 · 5 comments · May be fixed by #1062

Comments

@rasmus
Copy link
Member

rasmus commented Oct 20, 2021

As mentioned in #903, events with the same name created in different namespaces will collide. While there is a workaround using [EventVersion], the OOB experience should be that it should merely work.

An idea would be to create some settings that developers are forced to do during EventFlow initialization, like selecting the naming for events. Then introduce a new naming convention named NamespaceAndClassName along side the existing ClassName naming.

@github-actions
Copy link

github-actions bot commented Apr 8, 2023

Hello there!

We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days.
We consider this issue to be stale and will be closing it within the next seven days.

If you still require assistance with this issue, please feel free to reopen it or create a new issue.

Thank you for your understanding and cooperation.

Best regards,
EventFlow

@github-actions github-actions bot added the stale label Apr 8, 2023
@rasmus rasmus added stale-exempt and removed stale labels Apr 8, 2023
@github-actions
Copy link

github-actions bot commented Jul 8, 2023

Hello there!

We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days.
We consider this issue to be stale and will be closing it within the next seven days.

If you still require assistance with this issue, please feel free to reopen it or create a new issue.

Thank you for your understanding and cooperation.

Best regards,
EventFlow

@github-actions github-actions bot added the stale label Jul 8, 2023
@SeWaS
Copy link
Contributor

SeWaS commented Nov 2, 2023

Hello there 👋

I was thinking a bit about that problem recently. Let's see if I got that right: Wouldn't the EventDefinitionService be a potential place to apply such a naming strategy?

More precisely, as the method CreateDefinition(int version, Type type, string name) gets a version, type and name (either the event's classname or the value coming from the EventVersionAttribute) already injected, we could use those parameters, forward them to a strategy and get a strategy-applied eventname. Depending on the strategy, we might want to construct a name based on those values.

A default strategy could then be something like a VoidStrategy which simply returns the given name. That is the current behavior and thus would not introduce a breaking change.
A NamespaceAndClassName strategy could be provided as a built-in strategy which had to explicitly be picked when configuring EventFlow.
It would also be possible to allow devs to implement their own strategy and apply it.

Bottom line, the EventDefinitionService could look something like this:

protected override EventDefinition CreateDefinition(int version, Type type, string name)
{
    var strategyAppliedName = _eventFlowConfiguration.EventNamingStrategy
        .CreateEventName(version, type, name);
            
    return new EventDefinition(version, type, strategyAppliedName);
}

Hope that makes sense 😅 Any opinions or objections?

SeWaS added a commit to SeWaS/EventFlow that referenced this issue Nov 2, 2023
SeWaS added a commit to SeWaS/EventFlow that referenced this issue Dec 2, 2024
@SeWaS
Copy link
Contributor

SeWaS commented Dec 2, 2024

Any opinion here? Otherwise I would go ahead and open an PR based on SeWaS@28fad0b.

@rasmus
Copy link
Member Author

rasmus commented Dec 2, 2024

@SeWaS that would be awesome!

I had a look through your commit and maybe simply rely on the IEventNamingStrategy being in the IoC instead of a member on the configuration as that aligns more with the rest of the code base.

SeWaS added a commit to SeWaS/EventFlow that referenced this issue Dec 3, 2024
@SeWaS SeWaS linked a pull request Dec 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants