Class RowsSourceBase<TDerived, TOutput>
An abstract dataflow worker which repeatedly executes the OnOutputRowsDemandAsync()
method when there is RowsPerBuffer demand on the Output port.
The library user must inherit this class and override OnOutputRowsDemandAsync() to
provide custom functionality.
This class allows the developer to write synchronous or asynchronous code as needed,
without having to check for output demand (which simplifies the implementation), as long as
no more than RowsPerBuffer rows are sent on each invocation (or demand is checked for
explicitly).
The derived class can additionally override RunAsync() to add logic that runs
before and after all processing of rows, in which case the base class base.RunAsync()
must be called. The derived class (or its user) can also use
worker callbacks
to add logic.
Use RowsSourceBase<TDerived, TOutput, TError> instead if an ErrorOutput port is needed.
Also see the
RowsSourceBase
example.
Inheritance
Implements
Inherited Members
Namespace: actionETL
Assembly: actionETL.dll
Syntax
public abstract class RowsSourceBase<TDerived, TOutput> : WorkerBase<TDerived>, IDisposeOnFinished where TDerived : RowsSourceBase<TDerived, TOutput> where TOutput : class
Type Parameters
| Name | Description |
|---|---|
| TDerived | The type of the derived worker. Class definition example:
|
| TOutput | The type of each |
Constructors
RowsSourceBase(WorkerParent, String, Func<Boolean>)
Initializes a new instance of the RowsSourceBase<TDerived, TOutput, TError> abstract dataflow worker,
which repeatedly executes the OnOutputRowsDemandAsync method when there is
RowsPerBuffer demand on the Output port.
Declaration
protected RowsSourceBase(WorkerParent workerParent, string workerName, Func<bool> isStartableFunc)
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 |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| ArgumentNullException |
|
| InvalidOperationException |
|
Properties
Output
Gets the output port for sending rows to the downstream worker.
Declaration
public OutputPort<TOutput> Output { get; }
Property Value
| Type | Description |
|---|---|
| OutputPort<TOutput> |
Methods
OnOutputRowsDemandAsync()
An abstract method that gets called repeatedly when there is
RowsPerBuffer demand for more rows on the
Output port. Override it and call methods on the Output port and
ErrorOutput port (if present) to pass rows to the downstream workers.
On each invocation of this method there is a demand of at least RowsPerBuffer rows;
the method is not allowed to send more than this without checking for additional
demand with e.g. TrySendRow(TOutput). Alternatively you
can check for demand with HasBufferDemand, but then it is normally
easier to send no more than RowsPerBuffer rows and return, to get called again.
Declaration
protected abstract Task<ProgressStatus> OnOutputRowsDemandAsync()
Returns
| Type | Description |
|---|---|
| Task<ProgressStatus> |
|
RunAsync()
This method can be overridden to add custom functionality to the derived worker that runs before
and after the row processing. In this case, the base class base.RunAsync() must
be called for the worker to function correctly.
Typically, only OnOutputRowsDemandAsync() is overridden to add required custom logic.
Declaration
protected override async Task<OutcomeStatus> RunAsync()
Returns
| Type | Description |
|---|---|
| Task<OutcomeStatus> | A |