cq-rs / cqrs

An event-sourced command-query system for Rust
39 stars 9 forks source link

Add ability to get events and their associated metadata #3

Closed neoeinstein closed 5 years ago

neoeinstein commented 5 years ago

Makes it possible to retrieve metadata information out of the event store. Adds a demonstration to the cqrs-todoql-psql example.

neoeinstein commented 5 years ago

Right now, the cqrs-postgres implementations for read_events and read_events_with_metadata return Result<Option<Vec<Result<Event, E>>>, E>. Seems like we could clean that up by just returning a Result<Option<Vec<Event>>, E> Lazy loading may be useful, but I think we are better just relying on the caller asking for reasonable page sizes, since we are loading everything into a Vec right now anyway.

ajgajg1134 commented 5 years ago

Right now, the cqrs-postgres implementations for read_events and read_events_with_metadata return Result<Option<Vec<Result<Event, E>>>, E>. Seems like we could clean that up by just returning a Result<Option<Vec<Event>>, E> Lazy loading may be useful, but I think we are better just relying on the caller asking for reasonable page sizes, since we are loading everything into a Vec right now anyway.

Yeah I agree switching to Result<Option<Vec<Event>>, E> is a bit nicer for consumers. We can also add a lazy method later down the line if it's determined that would be useful to have

neoeinstein commented 5 years ago

See #4 for the change to simplify. We can merge that first, then I can fix up this PR to match.