Class CommandInterpreter.Builder
Represents builder of the interpreter.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft.Commands
Assembly: DotNext.Net.Cluster.dll
Syntax
public sealed class CommandInterpreter.Builder : ISupplier<CommandInterpreter>, IFunctional<Func<CommandInterpreter>>, IResettable
Methods
| Edit this page View SourceAdd<TCommand>(int, Func<TCommand, object?, CancellationToken, ValueTask>, bool)
Registers command handler.
Declaration
public CommandInterpreter.Builder Add<TCommand>(int commandId, Func<TCommand, object?, CancellationToken, ValueTask> handler, bool snapshotHandler = false) where TCommand : notnull, ISerializable<TCommand>
Parameters
Type | Name | Description |
---|---|---|
int | commandId | The identifier of the command. |
Func<TCommand, object, CancellationToken, ValueTask> | handler | The command handler. |
bool | snapshotHandler | true to register a handler for snapshot log entry; false to register a handler for regular log entry. |
Returns
Type | Description |
---|---|
CommandInterpreter.Builder | This builder. |
Type Parameters
Name | Description |
---|---|
TCommand | The type of the command supported by the handler. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GenericArgumentException | Type |
Add<TCommand>(int, Func<TCommand, CancellationToken, ValueTask>, bool)
Registers command handler.
Declaration
public CommandInterpreter.Builder Add<TCommand>(int commandId, Func<TCommand, CancellationToken, ValueTask> handler, bool snapshotHandler = false) where TCommand : notnull, ISerializable<TCommand>
Parameters
Type | Name | Description |
---|---|---|
int | commandId | The identifier of the command. |
Func<TCommand, CancellationToken, ValueTask> | handler | The command handler. |
bool | snapshotHandler | true to register a handler for snapshot log entry; false to register a handler for regular log entry. |
Returns
Type | Description |
---|---|
CommandInterpreter.Builder | This builder. |
Type Parameters
Name | Description |
---|---|
TCommand | The type of the command supported by the handler. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GenericArgumentException | Type |
Build()
Constructs an instance of CommandInterpreter.
Declaration
public CommandInterpreter Build()
Returns
Type | Description |
---|---|
CommandInterpreter | A new instance of the interpreter. |
Reset()
Clears this builder so it can be reused.
Declaration
public void Reset()