Class FlowModule
Base class for all modules, but you will probably use FlowModule<TSettings> for your implementation
public abstract class FlowModule : IFlowModule, IDisposable
- Inheritance
-
FlowModule
- Implements
- Derived
-
FlowModule<TSettings>
- Inherited Members
Constructors
FlowModule(FlowModuleType)
Constructor for FlowModule
protected FlowModule(FlowModuleType moduleType)
Parameters
moduleTypeFlowModuleType
Fields
InteractivityJsonOptions
public static readonly JsonSerializerOptions InteractivityJsonOptions
Field Value
Properties
AssemblyVersion
public string AssemblyVersion { get; set; }
Property Value
Categories
Sets the tags to be able to group modules together representing similar functionality
[JsonIgnore]
public List<string> Categories { get; set; }
Property Value
Debug
If true the module will log messages in/out from the module.
public bool Debug { get; set; }
Property Value
Description
[JsonIgnore]
public string Description { get; }
Property Value
Disabled
If true the module will ignore messages coming in
public bool Disabled { get; set; }
Property Value
FlowContext
Reference to the flow specific context that the module belongs to
[JsonIgnore]
public RepositoryInstance<string, dynamic> FlowContext { get; }
Property Value
- RepositoryInstance<string, dynamic>
FlowId
Id of the flow that the module belongs to
public Guid FlowId { get; set; }
Property Value
FlowName
public string FlowName { get; }
Property Value
FlowStatistics
[Obsolete("This property will be removed in the next major version")]
[JsonIgnore]
public FlowStatistics FlowStatistics { get; set; }
Property Value
HaltOnError
If true the module and flow will be stopped when OnError is called
public bool HaltOnError { get; set; }
Property Value
HasInput
If true you can pass data to this module
public bool HasInput { get; set; }
Property Value
HasInteractiveSupport
public virtual bool HasInteractiveSupport { get; }
Property Value
HasOutput
if Outputs Count is > 0 this will be true
public bool HasOutput { get; }
Property Value
Id
Unique Id for the module instance
public Guid Id { get; set; }
Property Value
Index
[JsonIgnore]
public int Index { get; set; }
Property Value
InteractiveMethods
Get all currently available interactive methods from the module. Can be overridden in derived classes i.e. lets derived class have another way of storing methods.
public virtual IEnumerable<KeyValuePair<(string Uri, string Method), Func<JsonElement, ILog?, Task<(object?, FlowError?)>>>> InteractiveMethods { get; }
Property Value
- IEnumerable<KeyValuePair<(string Uri, string Method), Func<JsonElement, ILog, Task<(object, FlowError)>>>>
InteractivityTopics
Get all registered methods from the module
public IEnumerable<(string Uri, string Method)> InteractivityTopics { get; }
Property Value
- IEnumerable<(string Uri, string Method)>
Logger
public ILog? Logger { get; }
Property Value
- ILog
MaxNrOfOutputs
The maximum number of outputs for the module, defaults to 1 so set this in your custom module if needed
[Obsolete("This property will be removed in the next major version")]
public int MaxNrOfOutputs { get; set; }
Property Value
ModuleProtocol
If the module uses a specific protocol for communication is should be registered here to make routers able to locate the module
[Obsolete("Modules that communicate via a specific protocol will solve the communication on their own")]
[JsonIgnore]
public FlowModuleProtocol ModuleProtocol { get; set; }
Property Value
ModuleStatistics
[Obsolete("This property will be removed in the next major version")]
[JsonIgnore]
public FlowModuleStatistics ModuleStatistics { get; set; }
Property Value
ModuleType
The module type implemented. See FlowModuleType
[JsonIgnore]
public FlowModuleType ModuleType { get; set; }
Property Value
ModuleVersion
public string ModuleVersion { get; set; }
Property Value
Name
Name of the module at runtime (set by users using the module in the flow)
public string Name { get; set; }
Property Value
NoError
protected static Task<IError?> NoError { get; }
Property Value
- Task<IError>
NrOfOutputs
The available number of outputs from the module
public int NrOfOutputs { get; }
Property Value
Remarks
Each output can have several modules connected to it
OnDebug
[JsonIgnore]
public EventHandler<ModuleDebugMessage>? OnDebug { get; set; }
Property Value
- EventHandler<ModuleDebugMessage>
OnError
[Obsolete("Use SetStatus instead")]
[JsonIgnore]
public EventHandler<FlowModuleException>? OnError { get; set; }
Property Value
OnFlowDataReceived
[JsonIgnore]
[Obsolete("This will be removed in the next major version")]
public EventHandler<FlowStatisticsData>? OnFlowDataReceived { get; set; }
Property Value
- EventHandler<FlowStatisticsData>
OnFlowDataSent
[JsonIgnore]
[Obsolete("This will be removed in the next major version")]
public EventHandler<FlowStatisticsData>? OnFlowDataSent { get; set; }
Property Value
- EventHandler<FlowStatisticsData>
OnMessageDeadLetter
[JsonIgnore]
public EventHandler<MessageEvent>? OnMessageDeadLetter { get; set; }
Property Value
OnMessageDropped
[JsonIgnore]
public EventHandler<MessageEvent>? OnMessageDropped { get; set; }
Property Value
OnModuleDataReceived
[JsonIgnore]
[Obsolete("This will be removed in the next major version")]
public EventHandler<FlowModuleStatisticsData>? OnModuleDataReceived { get; set; }
Property Value
- EventHandler<FlowModuleStatisticsData>
OnModuleDataSent
[JsonIgnore]
[Obsolete("This will be removed in the next major version")]
public EventHandler<FlowModuleStatisticsData>? OnModuleDataSent { get; set; }
Property Value
- EventHandler<FlowModuleStatisticsData>
OnStatusChanged
[JsonIgnore]
public EventHandler<ModuleStatusEvent>? OnStatusChanged { get; set; }
Property Value
OnWarning
[Obsolete("Use SetStatus instead")]
[JsonIgnore]
public EventHandler<FlowModuleException>? OnWarning { get; set; }
Property Value
Outputs
The actual outputs from the module
public List<RepositoryInstance<Guid, IFlowModule?>> Outputs { get; set; }
Property Value
- List<RepositoryInstance<Guid, IFlowModule>>
ReceivesInputFromMultipleModules
public bool ReceivesInputFromMultipleModules { get; set; }
Property Value
RemoteSessionEnabled
[JsonIgnore]
public bool RemoteSessionEnabled { get; set; }
Property Value
Resources
public IList<ResourceBase> Resources { get; set; }
Property Value
Settings
public FlowModuleSettings Settings { get; protected set; }
Property Value
SettingsUri
public string SettingsUri { get; }
Property Value
Status
[JsonIgnore]
public Status Status { get; }
Property Value
Topic
To get the topic for routing modules. This setting should be refactored with the ModuleType later on.
[Obsolete("Modules that communicate via a specific protocol will solve the communication on their own")]
[JsonIgnore]
public string? Topic { get; set; }
Property Value
Type
[JsonIgnore]
public string Type { get; }
Property Value
Uri
public string Uri { get; }
Property Value
UserFriendlyName
Name to present to users
public abstract string UserFriendlyName { get; }
Property Value
Methods
AddMethod<TParameters, TResult>(string, Func<TParameters, Task<(TResult, FlowError?)>>)
protected void AddMethod<TParameters, TResult>(string name, Func<TParameters, Task<(TResult, FlowError?)>> method)
Parameters
Type Parameters
TParametersTResult
AddMethod<TParameters, TResult>(string, string, Func<TParameters, Task<(TResult, FlowError?)>>)
protected void AddMethod<TParameters, TResult>(string uri, string name, Func<TParameters, Task<(TResult, FlowError?)>> method)
Parameters
Type Parameters
TParametersTResult
AddModuleMethod<TParameters, TResult>(string, Func<TParameters, Task<(TResult, FlowError?)>>)
protected void AddModuleMethod<TParameters, TResult>(string name, Func<TParameters, Task<(TResult, FlowError?)>> method)
Parameters
Type Parameters
TParametersTResult
AddSettingMethod<TParameters, TResult>(string, Func<TParameters, Task<(TResult, FlowError?)>>)
protected void AddSettingMethod<TParameters, TResult>(string name, Func<TParameters, Task<(TResult, FlowError?)>> method)
Parameters
Type Parameters
TParametersTResult
AllowMessageToEnterModule(IFlowMessage)
protected abstract bool AllowMessageToEnterModule(IFlowMessage message)
Parameters
messageIFlowMessage
Returns
BypassMessageNotMatchingRules()
protected abstract bool BypassMessageNotMatchingRules()
Returns
CanStart()
[Obsolete("This method will be removed in the next major version")]
public virtual IError? CanStart()
Returns
- IError
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
FlowDefinitionId()
public Guid FlowDefinitionId()
Returns
GetCredential(Guid)
This will return the Credential loaded into the Settings.Credential dictionary. If you need to download the resource use the IFlowCredentialsManagerService
[Obsolete("Use GetCredentialAsync instead")]
public IResult<Credential> GetCredential(Guid credentialId)
Parameters
credentialIdGuid
Returns
- IResult<Credential>
GetCredentialAsync(Guid)
If the credential is not found locally it will be downloaded. This call need all required services to be registered in the ServiceCollection. This is done by the runtime, but if you are using the method in a unit test you need to handle these requirements.
public Task<IResult<Credential>> GetCredentialAsync(Guid credentialId)
Parameters
credentialIdGuid
Returns
- Task<IResult<Credential>>
GetCredentialContentAs<T>(Guid)
This will return the Credential loaded into the Settings.Credential dictionary. If you need to download the resource use the IFlowCredentialsManagerService
[Obsolete("Use GetCredentialContentAsync instead")]
public IResult<T> GetCredentialContentAs<T>(Guid credentialId) where T : class, new()
Parameters
credentialIdGuid
Returns
- IResult<T>
Type Parameters
T
Exceptions
GetCredentialContentAsync<T>(Guid)
If the credential is not found locally it will be downloaded. This call need all required services to be registered in the ServiceCollection. This is done by the runtime, but if you are using the method in a unit test you need to handle these requirements.
public Task<IResult<T>> GetCredentialContentAsync<T>(Guid credentialId) where T : class, new()
Parameters
credentialIdGuid
Returns
- Task<IResult<T>>
Type Parameters
T
Exceptions
GetResource(Guid)
This will return the ResourceItem loaded into the Settings.Resources dictionary. If you need to download the resource use the IFlowResourceManagerService
[Obsolete("Use GetResourceAsync instead")]
public IResult<ResourceItem> GetResource(Guid resourceId)
Parameters
resourceIdGuid
Returns
- IResult<ResourceItem>
GetResourceAsync(Guid)
If the resource is not found locally it will be downloaded. This call need all required services to be registered in the ServiceCollection. This is done by the runtime, but if you are using the method in a unit test you need to handle these requirements.
public Task<IResult<ResourceItem>> GetResourceAsync(Guid resourceId)
Parameters
resourceIdGuid
Returns
- Task<IResult<ResourceItem>>
GetResourceContentAs<T>(Guid)
This will return the ResourceItem loaded into the Settings.Resources dictionary. If you need to download the resource use the IFlowResourceManagerService
[Obsolete("Use GetResourceContentAsync instead")]
public IResult<T> GetResourceContentAs<T>(Guid resourceId) where T : class, new()
Parameters
resourceIdGuid
Returns
- IResult<T>
Type Parameters
T
Exceptions
GetResourceContentAsync<T>(Guid)
If the resource is not found locally it will be downloaded. This call need all required services to be registered in the ServiceCollection. This is done by the runtime, but if you are using the method in a unit test you need to handle these requirements.
public Task<IResult<T>> GetResourceContentAsync<T>(Guid resourceId) where T : class, new()
Parameters
resourceIdGuid
Returns
- Task<IResult<T>>
Type Parameters
T
Exceptions
Initialize()
This method will be called when the flow is about to be started, but before the call to Start()
public virtual Task<IError?> Initialize()
Returns
- Task<IError>
An awaitable Task
InitializeInteractivity()
Override this method and register your module interactivity methods
public virtual void InitializeInteractivity()
InteractiveSessionRequest(string, string, JsonElement)
public Task<(object? result, FlowError? error)> InteractiveSessionRequest(string uri, string method, JsonElement parameters)
Parameters
uristringmethodstringparametersJsonElement
Returns
InteractiveSessionUri(string)
Obsolete method to get the interactive session URI. This method is deprecated and should be replaced with Uri and interpolated string. Uri
[Obsolete("Use Uri and interpolated string instead")]
public string InteractiveSessionUri(string uri)
Parameters
uristring
Returns
Interactivity()
public virtual ModuleInteractivity Interactivity()
Returns
LoadSettings(string)
public abstract void LoadSettings(string settingsAsJson)
Parameters
settingsAsJsonstring
MessageReceived(IFlowMessage)
Implement this method in your custom modules to implement logic for the FlowMessage passing through the module. If you want to pass data to the next IFlowModule you should call Next(params IFlowMessage[]) in this method
protected abstract Task MessageReceived(IFlowMessage message)
Parameters
messageIFlowMessageThe FlowMessage passed into the module
Returns
- Task
An awaitable Task
Next(params IFlowMessage[])
When you want to pass the message(s) to the next module(s) in the. This should be called from the MessageReceived(IFlowMessage) method.
protected Task Next(params IFlowMessage[] messages)
Parameters
messagesIFlowMessage[]The parameter is 0 to n FlowMessage"
Returns
- Task
An awaitable Task
Receive(IFlowMessage)
Passing data to this will flag the module to process the message. In most cases this will be done by the flow-engine or the flow but in special cases you can call this manually to trigger the processing of a message
public Task Receive(IFlowMessage message)
Parameters
messageIFlowMessageThe FlowMessage passed into the module
Returns
- Task
An awaitable Task
ReceiveFrom(IFlowModule, int)
Will register the module passed in as a receiver from this module. The module will will be registered at output index 0 by default
public IFlowModule ReceiveFrom(IFlowModule module, int ix = 0)
Parameters
moduleIFlowModuleThe module to receive data
ixintThe output-index to register the module on
Returns
SendTo(IFlowModule, int)
Will pass messages this module to the module passed in
public IFlowModule SendTo(IFlowModule module, int ix = 0)
Parameters
moduleIFlowModuleThe module that will receive the data
ixintThe output index to add the module to
Returns
- IFlowModule
The module that will receive the data (the module passed in)
SetNrOfOutputs(int)
protected void SetNrOfOutputs(int value)
Parameters
valueint
SetStatus(Status)
Set the Status of the module. If the current status is different the OnStatusChanged event will be triggered.
public void SetStatus(Status status)
Parameters
SetStatus(Status, string)
Set the Status of the module. If the current status is different the OnStatusChanged event will be triggered.
public void SetStatus(Status status, string message = "")
Parameters
statusStatusThe new Status
messagestringThe message to attach to the ModuleStatusEvent
SetStatus(Status, string, bool)
public void SetStatus(Status status, string message = "", bool force = false)
Parameters
SetStatus(Status, string, bool, Exception?)
Set the Status of the module. If the current status is different the OnStatusChanged event will be triggered.
public void SetStatus(Status status, string message = "", bool force = false, Exception? exception = null)
Parameters
statusStatusThe new Status
messagestringThe message to attach to the ModuleStatusEvent
forceboolPass true to force the OnStatusChanged event to be triggered regardless of current status
exceptionException
Start()
This method will be called when the flow is about to be started, but after the call to Initialize()
public virtual Task<IError?> Start()
Returns
- Task<IError>
A Crosser.EdgeNode.Common.Abstractions.Utilities.Errors.IError describing the error. If null there was no error.
Stop()
This method will be called when the flow is about to be stopped.
public virtual Task Stop()
Returns
- Task
An awaitable Task
UpdateFlowReceivedStatistics(long)
[Obsolete("This method will be removed in the next major version")]
protected void UpdateFlowReceivedStatistics(long size = 0)
Parameters
sizelong
UpdateFlowSentStatistics(long)
[Obsolete("This method will be removed in the next major version")]
protected void UpdateFlowSentStatistics(long size = 0)
Parameters
sizelong
UpdateModuleReceivedStatistics(long)
[Obsolete("This method will be removed in the next major version")]
protected void UpdateModuleReceivedStatistics(long size = 0)
Parameters
sizelong
UpdateModuleSentStatistics(long)
[Obsolete("This method will be removed in the next major version")]
protected void UpdateModuleSentStatistics(long size = 0)
Parameters
sizelong
ValidateSettings(SettingsValidator)
public virtual void ValidateSettings(SettingsValidator validator)
Parameters
validatorSettingsValidator