Class WorkerSystem
A class that creates and runs a system of workers. Typical use involves adding user logic with a Root(Action<WorkerSystem>) overload, and start the worker system with StartAsync() or Start().
To create a custom reusable worker system type, either inherit from this class (if retaining the Root(Action<WorkerSystem>) overloads), or from WorkerSystemBase<TDerived>.
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public class WorkerSystem : WorkerSystemBase<WorkerSystem>, IDisposeOnFinished
Constructors
WorkerSystem()
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will get the name "Root", and will look for the configuration settings file and the logging configuration file in the default locations.
Declaration
public WorkerSystem()
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(IConfigurationService)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will get the default name "Root", and look for the logging configuration file in the default locations.
Declaration
public WorkerSystem(IConfigurationService configurationService)
Parameters
Type | Name | Description |
---|---|---|
IConfigurationService | configurationService | The configuration service. If |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(IALogFactory)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will get the default name "Root", and look for the configuration settings file in the default locations.
Declaration
public WorkerSystem(IALogFactory logFactory)
Parameters
Type | Name | Description |
---|---|---|
IALogFactory | logFactory | The log factory. If |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(String)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will look for the configuration settings file and the logging configuration file in the default locations.
Declaration
public WorkerSystem(string workerSystemName)
Parameters
Type | Name | Description |
---|---|---|
String | workerSystemName | Name of the worker system, which will be the first level of the Locator string.
Defaults to Cannot contain "/", or start with double underscore "__". |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(String, IConfigurationService)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will look for the logging configuration file in the default locations.
Declaration
public WorkerSystem(string workerSystemName, IConfigurationService configurationService)
Parameters
Type | Name | Description |
---|---|---|
String | workerSystemName | Name of the worker system, which will be the first level of the Locator string.
Defaults to Cannot contain "/", or start with double underscore "__". |
IConfigurationService | configurationService | The configuration service. If |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(String, IConfigurationService, IALogFactory)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers.
Declaration
public WorkerSystem(string workerSystemName, IConfigurationService configurationService, IALogFactory logFactory)
Parameters
Type | Name | Description |
---|---|---|
String | workerSystemName | Name of the worker system, which will be the first level of the Locator string.
Defaults to Cannot contain "/", or start with double underscore "__". |
IConfigurationService | configurationService | The configuration service. If |
IALogFactory | logFactory | The log factory. If |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
WorkerSystem(String, IALogFactory)
Initializes a new instance of WorkerSystem, which is used to create and run a system of workers. It will look for the configuration settings file in the default locations.
Declaration
public WorkerSystem(string workerSystemName, IALogFactory logFactory)
Parameters
Type | Name | Description |
---|---|---|
String | workerSystemName | Name of the worker system, which will be the first level of the Locator string.
Defaults to Cannot contain "/", or start with double underscore "__". |
IALogFactory | logFactory | The log factory. If |
Exceptions
Type | Condition |
---|---|
Exception | (Various Newtonsoft.Json.JsonException license and configuration reading and parsing exceptions). |
FormatException | File parse error. |
IOException | An I/O error occurred. |
InvalidOperationException |
|
Methods
Root(Action<WorkerSystem>)
Specifies the synchronous action to run (which usually entails creating workers) when the
worker system is started. Using Root
means that the workers are only created (usually by
their direct parent) if and when needed, as specified by workers and their constraints.
Note that it is also possible to create and add workers to the worker system before the worker system has started, see the conceptual documentation for details.
Note: This method is thread-safe.
Declaration
public WorkerSystem Root(Action<WorkerSystem> action)
Parameters
Type | Name | Description |
---|---|---|
Action<WorkerSystem> | action | The callback to run. It receives the worker system as a parameter, which should be passed to any workers created directly under the root. If the action does not throw, the callback is assumed to have succeeded. |
Returns
Type | Description |
---|---|
WorkerSystem | The worker system, which e.g. can be used to call StartAsync(). |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
Root(Func<WorkerSystem, OutcomeStatus>)
Specifies the synchronous function to run (which usually entails creating workers) when the
worker system is started. Using Root
means that the workers are only created (usually by
their direct parent) if and when needed, as specified by workers and their constraints.
Note that it is also possible to create and add workers to the worker system before the worker system has started, see the conceptual documentation for details.
Note: This method is thread-safe.
Declaration
public WorkerSystem Root(Func<WorkerSystem, OutcomeStatus> func)
Parameters
Type | Name | Description |
---|---|---|
Func<WorkerSystem, OutcomeStatus> | func | The callback to run. It receives the worker system as a parameter, which should be passed to any workers created directly under the root. Must return an OutcomeStatus that describes success or failure of the callback. |
Returns
Type | Description |
---|---|
WorkerSystem | The worker system, which e.g. can be used to call StartAsync(). |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
Root(Func<WorkerSystem, Task<OutcomeStatus>>)
Specifies the asynchronous function to run (which usually entails creating workers) when the
worker system is started. Using Root
means that the workers are only created (usually by
their direct parent) if and when needed, as specified by workers and their constraints.
Note that it is also possible to create and add workers to the worker system before the worker system has started, see the conceptual documentation for details.
Note: This method is thread-safe.
Declaration
public WorkerSystem Root(Func<WorkerSystem, Task<OutcomeStatus>> funcAsync)
Parameters
Type | Name | Description |
---|---|---|
Func<WorkerSystem, Task<OutcomeStatus>> | funcAsync | The callback to run. It receives the worker system as a parameter, which should be passed to any workers created directly under the root. Must return an OutcomeStatus that describes success or failure of the callback. |
Returns
Type | Description |
---|---|
WorkerSystem | The worker system, which e.g. can be used to call StartAsync(). |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
Root(Func<WorkerSystem, Task>)
Specifies the asynchronous action to run (which usually entails creating workers) when the
worker system is started. Using Root
means that the workers are only created (usually by
their direct parent) if and when needed, as specified by workers and their constraints.
Note that it is also possible to create and add workers to the worker system before the worker system has started, see the conceptual documentation for details.
Note: This method is thread-safe.
Declaration
public WorkerSystem Root(Func<WorkerSystem, Task> actionAsync)
Parameters
Type | Name | Description |
---|---|---|
Func<WorkerSystem, Task> | actionAsync | The callback to run. It receives the worker system as a parameter, which should be passed to any workers created directly under the root. If the action does not throw, the callback is assumed to have succeeded. |
Returns
Type | Description |
---|---|
WorkerSystem | The worker system, which e.g. can be used to call StartAsync(). |
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
|
RunAsync()
The worker system calls this method during its Running phase. Override it to implement any worker system specific logic. This class uses it to implement the functionality of the Root(Action<WorkerSystem>) overloads.
If this method returns a Succeeded status and did not call an RunChildrenAsync() overload, then the system will run the workers.
Note that the worker system Running
phase also includes additional places where logic can
optionally be inserted via callbacks, to e.g. customize the initialization, cleanup,
and error handling.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
Type | Description |
---|---|
Task<OutcomeStatus> | An OutcomeStatus describing the success or failure of the worker system. |