Repository navigation
Bind EventMeta and IdempotencyKey directly on application traits - #2
Merged
Merged
Conversation
Add where-clause bounds so EventRepository/StateRepository require C: IdempotencyKey (dedup retried commands) and EventRepository/ViewRepository/ EventLoader require their event type params to implement EventMeta (secondary indexing). Restate the bounds on every handler that wraps these traits (EventSourcedCommandHandler, StateStoredCommandHandler, MaterializedViewHandler, EventSourcedQueryHandler), since Rust doesn't propagate a trait's own where-clause to external bound sites. Rewrite all doc examples to satisfy the new contract. Bump version to 0.3.0 for this breaking API change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Replace the hand-formatted "key:value" string convention with a Tag { key,
value } struct (Display produces the canonical "key:value" wire format).
This removes the risk of malformed tags from manual format!() calls, e.g. a
missing separator or a value containing a colon. EventMeta::tags() and
QueryTuple.tags now both return/hold Vec<Tag> instead of Vec<String>, keeping
events and queries structurally consistent. Update all doc examples
accordingly and bump version to 0.4.0.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add Send + Sync bounds to C/Ei/Eo on EventRepository, C/S on StateRepository, E/S on ViewRepository, and E on EventLoader (multi-threaded variants only). These types are moved into or held across the Send future each trait's methods already promise to return, so the bound was previously an unstated requirement left to each implementor to satisfy; making it explicit on the trait catches violations at the trait-bound level instead of deep inside an implementation's async fn body. Restate the bounds on every handler that wraps these traits, since Rust doesn't propagate a trait's own where-clause to external bound sites. Single-threaded variants are untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
QueryTuple is a plain, dependency-free data type (like Tag, EventMeta, IdempotencyKey) rather than an application-layer concern, so it belongs in lib.rs alongside them instead of inside event_sourced_query_handler.rs. EventLoader and EventSourcedQueryHandler now import it from crate root. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
EventRepository::execute currently has no way to know which events are relevant to a given command beyond a hardcoded single-stream lookup baked into each implementation. Introduce CommandQueries (implemented by the command type, returning Vec<QueryTuple>) so DCB-style repositories can fetch exactly the events matching the command's declared queries — the same pattern already used for IdempotencyKey (dedup) and EventMeta (event indexing), rather than threading an unnameable closure type through EventRepository's own generic parameters. Bind C: CommandQueries on both EventRepository variants and restate it on EventSourcedCommandHandler, consistent with how the other command/event capability traits are already handled. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add where-clause bounds so EventRepository/StateRepository require C: IdempotencyKey (dedup retried commands) and EventRepository/ViewRepository/ EventLoader require their event type params to implement EventMeta (secondary indexing). Restate the bounds on every handler that wraps these traits (EventSourcedCommandHandler, StateStoredCommandHandler, MaterializedViewHandler, EventSourcedQueryHandler), since Rust doesn't propagate a trait's own where-clause to external bound sites. Rewrite all doc examples to satisfy the new contract. Bump version to 0.3.0 for this breaking API change.