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

Additional metadata #81

Open
alexeyzimarev opened this issue Apr 9, 2022 · 5 comments
Open

Additional metadata #81

alexeyzimarev opened this issue Apr 9, 2022 · 5 comments
Labels
enhancement New feature or request rfc Request for comments

Comments

@alexeyzimarev
Copy link
Contributor

Thinking about what to add to the default meta.

  • Event source:
    • Aggregate type (as it's not necessarily encoded in the stream name)
    • Application name
    • Application version
  • Command type that triggered the event?
  • The actual date when the event was produced? (The created system meta of ESDB gets lost when migrating to another store)
  • Anything else?
@alexeyzimarev alexeyzimarev added rfc Request for comments enhancement New feature or request labels Apr 9, 2022
@JulianMay
Copy link

CorrelationId? CausationId?

I think it's fine to keep it tight for "defaults", should be easy for consumers to add specific stuff like:

  • Acting userId
  • Feature flags
  • Origin vector (device/webUi/migration/integration)

@alexeyzimarev
Copy link
Contributor Author

alexeyzimarev commented Apr 11, 2022

Correlation and causation id isn't easy as it would require commands to have an id. I am thinking about those too. Maybe the solution is to specify pre-defined header keys, and allow to pass a Metadata instance to the app service Handle.

Acting user id - yeah, we normally make it a part of the business (DoneBy property of each event), but maybe for impersonation scenarios, it would work differently.

Have you seen the Command API feature? The main issue with it is a missing context with all the important stuff, including the user identity. Again, it would work better if there would be a way to populate some of the properties from HttpContext, or have a convention to extract data from HttpContext and assign values to command properties.

Storing causation id would make little sense if commands aren't stored. You'd be having gaps in the sequence. It works fine with ESDB embedded projections and $correlationId as it gets populated for links and emitted events. But there, one event causes another event. On our side, it's a different flow, we have commands. Andrea Balducci talked about storing commands in Twitter, and I am thinking about the same for some time.

@JulianMay
Copy link

For CausationId i was only thinking about if the transition was caused by an event, having the commands as events would bridge this I agree.

I've been down the path of storing commands in eventstore, and found it useful for diagnostics but the first thing you'd want to archive (or simply discard) - we ended up only doing it for certain types of aggregates, writing "CommandHandled" events to a stream per aggregate ($"CommandsHandled-{streamId}"), and having those with a max age of 3 months (scavenging the rest).

I had not seen the Command API feature! Looks very neat :)

At my previous gig we would have an overload for dispatching command, which would take a "context enrichment", which was monoidic. The 'command dispatcher' could be wrapped so one instance was aware of being used in a http context (enriching metadata with userId etc.), while another would be used by process managers, being aware of which policy was being used etc..
I liked how this gave us a seam to isolate 'the metadata we always want for changes comming this way', while keeping the door open for additional case-specific metadata.

Lejdholt pushed a commit to Lejdholt/eventuous that referenced this issue Jun 16, 2022
@alexeyzimarev alexeyzimarev moved this to Todo in Eventuous Nov 4, 2022
@alexeyzimarev alexeyzimarev moved this from Todo to Hold in Eventuous Nov 4, 2022
@k3daevin
Copy link
Contributor

The actual date when the event was produced?
This would be very helpful for auditing. If Clients would like to know the State at a given Timestamp, this is not possible with the current API. You can display the events and load the aggregate or the state up to a particular event (providing a custom Store.Load-Function with count as parameter), but not to a Timestamp.
You could however achieve this by adding the Timestamp as a Domain property into each event. Although this feels like violating DDD principles.

(The created system meta of ESDB gets lost when migrating to another store)
I was wondering why the Timestamp is not included in StreamEvent.
Then the Timestamp might fit into Metadata.

A problem might be: what happens to old events when this new metadata is required? Set DateTime.Min or null?

If you have any plans on integrating the Creation Timestamp to the metadata, I'd love to contribute the Load-Functions for StateStore and AggregateStore with Timestamp as parameter.

Copy link
Contributor Author

Creation date meta field could default to server-side creation date by default, it will be a special case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc Request for comments
Projects
Status: Hold
Development

No branches or pull requests

3 participants