Class MixedSideEffectsResultHandler
- Assembly
- Cratis.Chronicle.dll
Handles a collection that mixes bare events and EventForEventSourceId returned from a reactor handler method.
[Singleton]
public class MixedSideEffectsResultHandler : IReactorSideEffectHandler
- Inheritance
-
MixedSideEffectsResultHandler
- Implements
- Inherited Members
- Extension Methods
Remarks
Bare events are appended to the event source id and metadata resolved from the ReactorContext
(the reactor's [EventStreamType] / [EventSourceType] attributes and ICanProvide* interfaces),
exactly as if returned on their own; each EventForEventSourceId keeps its own self-describing
metadata. All events are appended as a single transaction. Homogeneous collections are handled by
EventsResultHandler (all bare events) and EventsForEventSourceIdResultHandler
(all EventForEventSourceId); this handler covers only the mixed case.
Constructors
MixedSideEffectsResultHandler()
Initializes a new instance of the MixedSideEffectsResultHandler class for the current per-store contract.
public MixedSideEffectsResultHandler()
MixedSideEffectsResultHandler(IEventTypes)
Initializes a new instance of the MixedSideEffectsResultHandler class for compatibility with the previous event-store-less contract.
public MixedSideEffectsResultHandler(IEventTypes eventTypes)
Parameters
eventTypesIEventTypesIEventTypes used when the event-store-less
CanHandleoverload is called without a current event store on its ReactorContext.
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.