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

Added sample of Event Bus with superpowers #78

Merged
merged 8 commits into from Nov 25, 2021

Conversation

oskardudycz
Copy link
Owner

@oskardudycz oskardudycz commented Oct 30, 2021

List of superpowers:

  • filtering,
  • transformation 1:1 and 1:N events into events,
  • no requirement for a marker interface for events,
  • no requirement for marker interfaces for handlers: supports pure function with wrappers,
  • but if you really want, you can have interfaces,
  • supports IoC, but also allow manual composition,
  • can be plugged into MediatR if you want.

@oskardudycz oskardudycz force-pushed the samples/event-pipelines branch 2 times, most recently from 2e7b34f to 7aa30f4 Compare October 31, 2021 08:51
Copy link

@kbroniek kbroniek left a comment

Choose a reason for hiding this comment

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

Consider implementing a query method as well.

Comment on lines +61 to +63
async ValueTask<object?> IEventHandler.Handle(object @event, CancellationToken ct)
{
return await Handle((TEvent)@event, ct);

Choose a reason for hiding this comment

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

Suggested change
async ValueTask<object?> IEventHandler.Handle(object @event, CancellationToken ct)
{
return await Handle((TEvent)@event, ct);
ValueTask<object?> IEventHandler.Handle(object @event, CancellationToken ct)
{
return Handle((TEvent)@event, ct);

Copy link
Owner Author

Choose a reason for hiding this comment

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

@kbroniek, thank you for the suggestion. This sample is more focused on the Events Broadcast, so publishing events to subscribers. Do you see potential in that? My intent wasn't to replace MediatR, but indeed that approach could also work for any processing 🤔 Thoughts?

Choose a reason for hiding this comment

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

OK. It will be nice to add a benchmark, but I know it will consume your time that we don't have these days.
Thought you could implement this as .net events or take advantage of source code generation. It could be fast then.
What if we add multiple handlers in the multi-threading app. Consider using ConcurrentDictionary.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Fair points. I added an issue for that: #85. I'll tackle that in a dedicated PR, as this branch is living too long. It's about time to kill it 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants