Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Middleware convention for Marten command handlers #721

Closed
jeremydmiller opened this issue Jun 5, 2022 · 0 comments
Closed

Middleware convention for Marten command handlers #721

jeremydmiller opened this issue Jun 5, 2022 · 0 comments
Milestone

Comments

@jeremydmiller
Copy link
Member

The goal here is to make it as easy as possible to have a handler method that:

  1. Uses Marten's FetchForWriting() method to find the right aggregate for the command
  2. Takes in a command message, a Marten event sourced aggregate (or the handle method is on the actual aggregate), and any other arguments for other services
  3. applies any cascading events to the event stream for the aggregate
  4. Calls `IDocumentSession.SaveChangesAsync()
[MartenAggregate]
public class SomeAggregate
{
    SpecificEvent Handle(SomeCommand cmd);

    void Handle(IncomingEvent @event, IEventStream stream);

    IEnumerable<object> Handle(SomeCommand cmd);

    Task<SpecificEvent> Handle(SomeCommand cmd);

    Task Handle(SomeCommand cmd, IEventStream stream);
}

or

public class AnyClass
{
    Task Handle(Command cmd, Aggregate aggregate, IEventStream);
}
@jeremydmiller jeremydmiller added this to the 2.0 milestone Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant