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
View SourceCommandInterpreter()
Initializes a new interpreter and discovers methods marked with CommandInterpreter.CommandHandlerAttribute attribute.
Declaration
[RequiresUnreferencedCode("Dynamic code generation may be incompatible with IL trimming")]
[RequiresDynamicCode("Runtime binding requires dynamic code compilation")]
protected CommandInterpreter()
Methods
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, CancellationToken) 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, CancellationToken) method.
Exceptions
| Type | Condition |
|---|---|
| CommandInterpreter.UnknownCommandException | The command handler was not registered for the command represented by |
| OperationCanceledException | The operation has been canceled. |