Interface IReactors

Namespace
Cratis.Chronicle.Reactors
Assembly
Cratis.Chronicle.dll

Defines a system for working with Reactor registrations for the Kernel.

public interface IReactors
Extension Methods

Methods

Define(ReactorId, Action<IReactorBuilder>)

Define a reactor fluently, without registering it.

IReactorDefinition Define(ReactorId id, Action<IReactorBuilder> define)

Parameters

id ReactorId

The stable reactor identifier.

define Action<IReactorBuilder>

Declares the reactor's handlers, event sequence and replay policy on an IReactorBuilder.

Returns

IReactorDefinition

The IReactorDefinition, which can be inspected and then registered with Register(IReactorDefinition).

Remarks

Event types are resolved against the event types this client knows at the time of the call, which is also what an all-events subscription is expanded to.

Exceptions

NoEventTypesForReactor

Thrown when the definition subscribes to no event types.

TypeIsNotAnEventType

Thrown when a typed handler names a type that is not a known event type.

Discover()

Discover all Reactors from the entry assembly and dependencies.

Task Discover()

Returns

Task

Awaitable task.

FastForward(ReactorId)

Fast forward a specific reactor by its identifier to the tail of the event log, skipping every event it has not yet handled without invoking it.

Task<FastForwardResult> FastForward(ReactorId reactorId)

Parameters

reactorId ReactorId

ReactorId to fast forward.

Returns

Task<FastForwardResult>

The FastForwardResult describing what happened.

FastForward<TReactor>()

Fast forward a reactor to the tail of the event log, skipping every event it has not yet handled without invoking it.

Task<FastForwardResult> FastForward<TReactor>() where TReactor : IReactor

Returns

Task<FastForwardResult>

The FastForwardResult describing what happened.

Type Parameters

TReactor

Type of reactor to fast forward.

GetFailedPartitionsFor(Type)

Get any failed partitions for a specific reactor.

Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor(Type reactorType)

Parameters

reactorType Type

Type of reducer.

Returns

Task<IEnumerable<FailedPartition>>

Collection of FailedPartition, if any.

GetFailedPartitionsFor<TReactor>()

Get any failed partitions for a specific reactor.

Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor<TReactor>()

Returns

Task<IEnumerable<FailedPartition>>

Collection of FailedPartition, if any.

Type Parameters

TReactor

Type of reducer.

GetHandlerById(ReactorId)

Gets a specific handler by its ReactorId.

IReactorHandler GetHandlerById(ReactorId id)

Parameters

id ReactorId

ReactorId to get for.

Returns

IReactorHandler

ReactorHandler instance.

GetHandlerFor(Type)

Gets the registered handler for a reactor CLR type.

IReactorHandler GetHandlerFor(Type reactorType)

Parameters

reactorType Type

The reactor CLR type.

Returns

IReactorHandler

The registered handler.

Exceptions

TypeBasedArtifactRegistrationNotSupported

The custom registry does not support type-based lookup.

GetHandlerFor<TReactor>()

Gets a specific handler by its TReactor type.

IReactorHandler GetHandlerFor<TReactor>() where TReactor : IReactor

Returns

IReactorHandler

ReactorHandler instance.

Type Parameters

TReactor

The reactor type.

GetStateFor(Type)

Gets a registered reactor's state.

Task<ReactorState> GetStateFor(Type reactorType)

Parameters

reactorType Type

The reactor CLR type.

Returns

Task<ReactorState>

The reactor state.

Exceptions

TypeBasedArtifactRegistrationNotSupported

The custom registry does not support type-based state lookup.

GetStateFor<TReactor>()

Get the state of a specific reactor.

Task<ReactorState> GetStateFor<TReactor>() where TReactor : IReactor

Returns

Task<ReactorState>

ReactorState.

Type Parameters

TReactor

Type of reactor get for.

Register()

Register all Reactors with Chronicle.

Task Register()

Returns

Task

Awaitable task.

Register(IReactorDefinition)

Register a reactor from a fluent definition.

Task<IReactorHandler> Register(IReactorDefinition definition)

Parameters

definition IReactorDefinition

The IReactorDefinition to register.

Returns

Task<IReactorHandler>

The registered handler, which can be inspected for state and failed partitions.

Remarks

The reactor is an ordinary Chronicle reactor: it has an observer of its own, subscribed to exactly the definition's EventTypes, and it has state, failed partitions and replay like a discovered reactor has. Each delivered event is deserialized to its CLR type and passed to Handle(object, EventContext). The registration is sent to Chronicle immediately, and is sent again whenever the connection is re-established. Delegate handlers report ReactorType as object.

Exceptions

ReactorAlreadyRegistered

Thrown when the identifier already belongs to a reactor in this client.

Register(ReactorId, Action<IReactorBuilder>)

Define and register a reactor fluently, with typed and catch-all handlers.

Task<IReactorHandler> Register(ReactorId id, Action<IReactorBuilder> define)

Parameters

id ReactorId

The stable reactor identifier.

define Action<IReactorBuilder>

Declares the reactor's handlers, event sequence and replay policy on an IReactorBuilder.

Returns

Task<IReactorHandler>

The registered handler, which can be inspected for state and failed partitions.

Remarks

Exceptions

NoEventTypesForReactor

Thrown when the definition subscribes to no event types.

TypeIsNotAnEventType

Thrown when a typed handler names a type that is not a known event type.

ReactorAlreadyRegistered

Thrown when the identifier already belongs to a reactor in this client.

Register(ReactorId, Action<IReactorDefinitionBuilder>, Func<ReactorEvent, CancellationToken, Task>)

Registers a reactor from an explicit event subscription and an awaited callback.

Task<IReactorHandler> Register(ReactorId id, Action<IReactorDefinitionBuilder> configure, Func<ReactorEvent, CancellationToken, Task> handle)

Parameters

id ReactorId

The stable reactor identifier.

configure Action<IReactorDefinitionBuilder>

Configures the event types, sequence, and replay policy.

handle Func<ReactorEvent, CancellationToken, Task>

Handles each delivered event; successful completion acknowledges the event.

Returns

Task<IReactorHandler>

The registered handler, which can be inspected for state and failed partitions.

Remarks

Delegate handlers report ReactorType as object.

Exceptions

NoEventTypesForReactor

Thrown when no event types are configured.

ReactorAlreadyRegistered

Thrown when the identifier already belongs to a reactor in this client.

Register(Type)

Registers a reactor type using this store's declarations.

Task<IReactorHandler> Register(Type reactorType)

Parameters

reactorType Type

The reactor CLR type.

Returns

Task<IReactorHandler>

The registered handler.

Exceptions

TypeBasedArtifactRegistrationNotSupported

The custom registry does not support type-based registration.

Register<TReactor>()

Registers a TReactor reactor with Chronicle.

Task<IReactorHandler> Register<TReactor>() where TReactor : IReactor

Returns

Task<IReactorHandler>

Awaitable task.

Type Parameters

TReactor

The reactor type.

Replay(ReactorId)

Replay a specific reactor by its identifier.

Task<JobId> Replay(ReactorId reactorId)

Parameters

reactorId ReactorId

ReactorId to replay.

Returns

Task<JobId>

The JobId of the replay job that was started or resumed, or NotSet if the reactor is not replayable or its observer is not in a state it can replay from (disconnected, quarantined); reconnect or release it before replaying.

Replay(Type)

Replays a registered reactor CLR type.

Task<JobId> Replay(Type reactorType)

Parameters

reactorType Type

The reactor CLR type.

Returns

Task<JobId>

The replay job identifier.

Exceptions

TypeBasedArtifactRegistrationNotSupported

The custom registry does not support type-based replay.

Replay<TReactor>()

Replay a specific reactor.

Task<JobId> Replay<TReactor>() where TReactor : IReactor

Returns

Task<JobId>

The JobId of the replay job that was started or resumed, or NotSet if the reactor is not replayable or its observer is not in a state it can replay from (disconnected, quarantined); reconnect or release it before replaying.

Type Parameters

TReactor

Type of reactor to replay.

Unregister(ReactorId)

Unregisters a reactor in this client, disconnecting its observation stream. An unknown identifier is ignored.

void Unregister(ReactorId id)

Parameters

id ReactorId

The reactor identifier to unregister.