Class CommandInterpreter
Represents interpreter of the log entries.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft.Commands
Assembly: DotNext.Net.Cluster.dll
Syntax
public class CommandInterpreter : Disposable, IDisposable, IBuildable<CommandInterpreter, CommandInterpreter.Builder>
Remarks
The interpreter can be constructed in two ways: using CommandInterpreter.Builder and through inheritance. If you choose the inheritance then command handlers must be declared as public instance methods marked with CommandInterpreter.CommandHandlerAttribute attribute. Otherwise, command handlers can be registered through the builder.
Constructors
| Edit this page View SourceCommandInterpreter()
Initializes a new interpreter and discovers methods marked with CommandInterpreter.CommandHandlerAttribute attribute.
Declaration
protected CommandInterpreter()
Methods
| Edit this page View SourceInterpretAsync<TEntry>(TEntry, object?, CancellationToken)
Interprets log entry asynchronously.
Declaration
public ValueTask<int> InterpretAsync<TEntry>(TEntry entry, object? context, CancellationToken token = default) where TEntry : IRaftLogEntry
Parameters
Type | Name | Description |
---|---|---|
TEntry | entry | The log entry to be interpreted. |
object | context | The context to be passed to the handler. |
CancellationToken | token | The token that can be used to cancel the interpretation. |
Returns
Type | Description |
---|---|
ValueTask<int> | The ID of the interpreted log entry. |
Type Parameters
Name | Description |
---|---|
TEntry | The type of the log entry to be interpreted. |
Remarks
Typically this method is called by the custom implementation of ApplyAsync(LogEntry) method.
Exceptions
Type | Condition |
---|---|
CommandInterpreter.UnknownCommandException | The command handler was not registered for the command represented by |
OperationCanceledException | The operation has been canceled. |
InterpretAsync<TEntry>(TEntry, CancellationToken)
Interprets log entry asynchronously.
Declaration
public ValueTask<int> InterpretAsync<TEntry>(TEntry entry, CancellationToken token = default) where TEntry : IRaftLogEntry
Parameters
Type | Name | Description |
---|---|---|
TEntry | entry | The log entry to be interpreted. |
CancellationToken | token | The token that can be used to cancel the interpretation. |
Returns
Type | Description |
---|---|
ValueTask<int> | The ID of the interpreted log entry. |
Type Parameters
Name | Description |
---|---|
TEntry | The type of the log entry to be interpreted. |
Remarks
Typically this method is called by the custom implementation of ApplyAsync(LogEntry) method.
Exceptions
Type | Condition |
---|---|
CommandInterpreter.UnknownCommandException | The command handler was not registered for the command represented by |
OperationCanceledException | The operation has been canceled. |