Class ActionWorkerBase<TDerived>
An abstract worker which accepts a callback to specify what it should do, which can include creating child workers.
This class must be inherited. The most common use case is to create a custom worker
where the user supplies a callback that the custom worker will execute, and the
custom worker also overrides RunAsync() to add additional logic.
Note that when overriding this RunAsync()
, the base class
base.RunAsync()
must be called.
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public abstract class ActionWorkerBase<TDerived> : WorkerBase<TDerived>, IDisposeOnFinished where TDerived : ActionWorkerBase<TDerived>
Type Parameters
Name | Description |
---|---|
TDerived | The type of the derived worker, which will be passed as a parameter to the anonymous method. Class definition example:
|
Constructors
ActionWorkerBase(WorkerParent, String, Func<Boolean>, Action<TDerived>)
Initializes a new instance of the ActionWorkerBase<TDerived> abstract worker that will execute a synchronous action.
Declaration
protected ActionWorkerBase(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Action<TDerived> action)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Action<TDerived> | action | The synchronous action to execute, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
ActionWorkerBase(WorkerParent, String, Func<Boolean>, Func<TDerived, OutcomeStatus>)
Initializes a new instance of the ActionWorkerBase<TDerived> abstract worker that will execute a synchronous function.
Declaration
protected ActionWorkerBase(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<TDerived, OutcomeStatus> func)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<TDerived, OutcomeStatus> | func | The synchronous function to execute, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
ActionWorkerBase(WorkerParent, String, Func<Boolean>, Func<TDerived, Task<OutcomeStatus>>)
Initializes a new instance of the ActionWorkerBase<TDerived> abstract worker that will execute an asynchronous function.
Declaration
protected ActionWorkerBase(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<TDerived, Task<OutcomeStatus>> funcAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<TDerived, Task<OutcomeStatus>> | funcAsync | The asynchronous function to execute, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
ActionWorkerBase(WorkerParent, String, Func<Boolean>, Func<TDerived, Task>)
Initializes a new instance of the ActionWorkerBase<TDerived> abstract worker that will execute an asynchronous action.
Declaration
protected ActionWorkerBase(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc, Func<TDerived, Task> actionAsync)
Parameters
Type | Name | Description |
---|---|---|
WorkerParent | workerParent | The parent worker or worker system that the new child worker will be added to. Cannot be |
String | workerName | Name of the worker.
Set to a prefix plus a trailing
While less useful, set to
The name cannot otherwise contain |
Func<Boolean> | isStartableFunc | Function to calculate the worker start constraint; it should return |
Func<TDerived, Task> | actionAsync | The asynchronous action to execute, optionally creating child workers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentException |
|
ArgumentNullException |
|
InvalidOperationException |
|
Methods
RunAsync()
Calls the user supplied callback.
This method is called by the system during the worker Running
phase. It can be overridden to add custom functionality to the derived worker,
in which case the base class base.RunAsync()
must be called for the worker
to function correctly.
Note that the worker Running
phase also includes additional places where logic can
optionally be inserted via callbacks, to e.g. customize the initialization, cleanup,
and error handling of existing workers. This is mostly used when customizing workers that
are not designed to be derived from (i.e. without a "Base" suffix).
See
Worker Life-cycle for details.
Declaration
protected override Task<OutcomeStatus> RunAsync()
Returns
Type | Description |
---|---|
Task<OutcomeStatus> | A Task<TResult> describing the success or failure of the worker.
An asynchronous |