-
Notifications
You must be signed in to change notification settings - Fork 125
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
Allow to define source of default streams when publishing events #1739
Comments
Does it assume you always append one event, as in the examples? If it allows many events, does it group them by streams and executes multiple appends — one per stream? My gut feeling is — this is fine for a framework on top of RES. And then perhaps a definition of go-to stream should be close to the definition of the event. |
I was thinking that there's no need to consider multiple events when doing
Where is it then (that I don't see a problem in reimplementing per se (we don't owe anyone particular features), but with that we're blocking ourselves from implementing smarter RES-Browser. It won't be easy to implement some, for example, versioning functionality on the browser without at least providing some commonly agreed API on it (like "What was the previous version of that event?").
That I agree, the example was just to be simple example, but |
As an additional highlight, if you're worried about backwards compatibility, we may mark this as experimental feature for some time: https://railseventstore.org/docs/v2/maintenance_policy/#experimental-features |
I know that more-than-one project are not using publishing though event store directly:
Because of requirement to always pass stream name, which seems very reasonable when you read the docs, but in practice seem very tedious, since you end up with copy-pasting stream name everywhere, so people end up with some facades over event store to relieve that, so that you can publish your events without specifying stream name each time, and instead "fetch it" from different place. This is less of a problem in greenfield, event-sourcing or very neatly bounded systems, but you pretty much have to face that issue in legacy environments.
Examples I've saw:
event_store.publish(OrderPublished.new(...))
.event_store
here is a wrapper over RES, which inside has a mapping likeOrderPublished => ->(event) { "Order$#{event.data.fetch(:order_id)}" }
Event.publish!(OrderPublished.new(...), order)
, which inside have a mapping from an object (order
) to the stream to which this event is relevant.I think the problem is common enough, that it would make sense to provide ability to set up some kind of
StreamsNameProvider
(name is WIP), which would be able to answer the questions about the streams for given event.We would preserve current behaviour by allowing to override these defaults by the
stream_name:
keyword argument, as it is now.An example implementation of such provider within a project:
This seem flexible enough to cover most of production cases, and should be relatively easy for extension. To be clear, I am willing to implement it, but I'm opening a discussion.
WDYT?
The text was updated successfully, but these errors were encountered: