Class EventsForEventSourceIdResultHandler
- Assembly
- Cratis.Chronicle.dll
Handles a non-empty collection of EventForEventSourceId returned from a reactor handler method.
[Singleton]
public class EventsForEventSourceIdResultHandler : IReactorSideEffectHandler
- Inheritance
-
EventsForEventSourceIdResultHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
Matches both a statically typed IEnumerable<T> of EventForEventSourceId and an IEnumerable<T> of object whose elements are all EventForEventSourceId, so the events are not silently dropped when the handler method declares a less specific return type. Each event carries its own append-metadata (event source id, stream type and id, source type, subject, occurred time and causation), so a single return can target multiple event source ids. All events are appended as one transaction. Unlike EventsResultHandler, no metadata is resolved from the ReactorContext.
Constructors
EventsForEventSourceIdResultHandler()
public EventsForEventSourceIdResultHandler()
Methods
CanHandle(ReactorContext, IEventStore, object)
Determines whether this handler can process the given return value.
public bool CanHandle(ReactorContext reactorContext, IEventStore eventStore, object value)
Parameters
reactorContextReactorContextThe ReactorContext for the reactor invocation.
eventStoreIEventStoreThe IEventStore the reactor is running under.
valueobjectThe value returned by the reactor handler method.
Returns
Remarks
The event store is passed per call rather than captured, because everything it exposes — the event type registry in particular — belongs to the namespace the resolving scope named. A handler that holds one is answering for whichever namespace happened to build it first.
Defaults to the event-store-less overload so a handler written against the previous contract keeps working unchanged. Implementations that need event-store-specific state can override this overload while retaining the previous one for callers compiled against the published contract.
CanHandle(ReactorContext, object)
Determines whether this handler can process the given return value.
public bool CanHandle(ReactorContext reactorContext, object value)
Parameters
reactorContextReactorContextThe ReactorContext for the reactor invocation.
valueobjectThe value returned by the reactor handler method.
Returns
Handle(ReactorContext, IEventStore, object)
Processes the return value, typically by appending one or more events to an event sequence.
public Task<Result<ReactorSideEffectFailure>> Handle(ReactorContext reactorContext, IEventStore eventStore, object value)
Parameters
reactorContextReactorContextThe ReactorContext for the reactor invocation.
eventStoreIEventStoreThe IEventStore to use for appending events.
valueobjectThe value returned by the reactor handler method.
Returns
- Task<Result<ReactorSideEffectFailure>>
A Task representing the asynchronous operation.