Plugin Development
Plugins are identified by method signature only. While there are ICommandPlugin and IEndpointPlugin interfaces, their usage is not mandatory.
All plugin operations are also cooperative in nature. For example, once engine sends control to any of the plugin methods (e.g., ReceiveAsync), it will wait until control is returned before proceeding.
There are two kinds of plugins: Command and Endpoint.
- Command plugin executes an action that is not dependant on the external systems
- Endpoint plugin allows for handling of messages to/from external system
Command Plugin
The following methods must be defined for all command plugins:
static Task<AASeqNodes> ExecuteAsync(ILogger logger, AASeqNodes parameters, CancellationToken cancellationToken)
ExecuteAsync Method
This static method will attempt to execute an command.
It accepts the following arguments:
logger: used to log any troubleshooting informationparameters: any parameters needed; this is a cloned version that can be freely modifiedcancellationToken: token for handling timeouts; its usage is not mandatory if operation has short duration
Returns executed nodes.
Method should raise exception in the case of invalid parameters.
Endpoint Plugin
The following methods must be defined for all endpoint plugins:
static Object CreateInstance(ILogger logger, AASeqNodes configuration)Task StartAsync(CancellationToken cancellationToken)Task<AASeqNodes> SendAsync(Guid id, string messageName, AASeqNodes parameters, CancellationToken cancellationToken)Task<Tuple<string, AASeqNodes>> ReceiveAsync(Guid id, string messageName, CancellationToken cancellationToken)
CreateInstance Method
This static method will return the instance of the endpoint.
It accepts the following arguments:
logger: used to log any troubleshooting informationconfiguration: any configuration needed; this is a cloned version that can be freely modified
Returns plugin object.
Method should raise exception in the case of invalid configuration only. No attempt to start endpoint should be done at this time.
StartAsync Method
Starts endpoint processing.
It accepts the following arguments:
cancellationToken: token for handling timeouts; its usage is not mandatory if operation has short duration
Returns nothing.
Method should raise exception in the case endpoint cannot be started.
Exception should be thrown only if configuration is erroneous. Opening of connection should not be done here but in a separate start method.
StartAsync Method
Starts any necessary connection.
SendAsync Method
Attempts to send a message.
It accepts the following arguments:
id: provided is used to match with message received inReceive(if needed)messageName: contains name of the message to sendparameters: any parameters needed; this is a cloned version that can be freely modifiedcancellationToken: token for handling timeouts; its usage is not mandatory if operation has short duration
Returns sent nodes.
Method can raise exceptions.
ReceiveAsync Method
Attempts to receive a message.
It accepts the following arguments:
id: provided is used to match with message sent inSend(if needed)parameters: any parameters needed; this is a cloned version that can be freely modifiedcancellationToken: token for handling timeouts; its usage is not mandatory if operation has short duration
Return is a tuple containing received message name (messageName) and any data (data).
Method can raise exceptions.
Variable Plugin
The following methods must be defined for all variable plugins:
static string? GetVariableValue(ILogger logger, string argument)
GetVariableValue Method
This static method will attempt to return a variable value.
It accepts the following arguments:
logger: used to log any troubleshooting informationargument: argument to the variable
Returns variable value or null if variable value cannot be determined.
Method should not raise exceptions.