Class BasePropagatorBlock<TInput, TOutput>
- Namespace
- DotnetKit.DataflowBuilder.Abstractions
- Assembly
- DotnetKit.DataflowBuilder.dll
Base class for custom propagator blocks that combine an internal target block and source block into an encapsulated IPropagatorBlock<TInput, TOutput>.
public abstract class BasePropagatorBlock<TInput, TOutput> : IPropagatorBlock<TInput, TOutput>, ITargetBlock<TInput>, ISourceBlock<TOutput>, IDataflowBlock
Type Parameters
TInputThe type of items accepted by the target end of the block.
TOutputThe type of items produced by the source end of the block.
- Inheritance
-
BasePropagatorBlock<TInput, TOutput>
- Implements
-
IPropagatorBlock<TInput, TOutput>ITargetBlock<TInput>ISourceBlock<TOutput>
- Derived
- Inherited Members
Properties
Completion
Gets a Task that represents the asynchronous operation and completion of the dataflow block.
public virtual Task Completion { get; }
Property Value
Pipeline
public IPropagatorBlock<TInput, TOutput> Pipeline { get; }
Property Value
- IPropagatorBlock<TInput, TOutput>
Source
Gets the inner source block responsible for dispatching outgoing messages.
public abstract ISourceBlock<TOutput> Source { get; }
Property Value
- ISourceBlock<TOutput>
Target
Gets the inner target block responsible for receiving incoming messages.
public abstract ITargetBlock<TInput> Target { get; }
Property Value
- ITargetBlock<TInput>
Methods
Complete()
Signals the target block that no more data will be provided, and propagates completion to the source block.
public virtual void Complete()
ConsumeMessage(DataflowMessageHeader, ITargetBlock<TOutput>, out bool)
Consumes a previously reserved message from the source block.
public virtual TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
Parameters
messageHeaderDataflowMessageHeaderThe header of the message being consumed.
targetITargetBlock<TOutput>The target block consuming the message.
messageConsumedboolSet to true if the message was successfully consumed; otherwise, false.
Returns
- TOutput
The consumed message value, or default if the message could not be consumed.
Fault(Exception)
Causes the encapsulated dataflow block to complete in a faulted state with the specified exception.
public virtual void Fault(Exception exception)
Parameters
exceptionExceptionThe exception that caused the fault.
LinkTo(ITargetBlock<TOutput>, DataflowLinkOptions)
Links this source block to the specified target block with the given link options.
public virtual IDisposable LinkTo(ITargetBlock<TOutput> target, DataflowLinkOptions linkOptions)
Parameters
targetITargetBlock<TOutput>The target block to link to.
linkOptionsDataflowLinkOptionsOptions defining the link behavior, such as completion propagation.
Returns
- IDisposable
An IDisposable that can be used to unlink the source and target blocks.
OfferMessage(DataflowMessageHeader, TInput, ISourceBlock<TInput>?, bool)
Offers a message to the target block and yields status regarding its consumption or rejection.
public virtual DataflowMessageStatus OfferMessage(DataflowMessageHeader messageHeader, TInput messageValue, ISourceBlock<TInput>? source, bool consumeToAccept)
Parameters
messageHeaderDataflowMessageHeaderThe header identifying the offered message.
messageValueTInputThe message payload being offered.
sourceISourceBlock<TInput>The source block offering the message, or null.
consumeToAcceptboolWhether the target must consume the message to accept it.
Returns
- DataflowMessageStatus
The acceptance status of the offered message.
ReleaseReservation(DataflowMessageHeader, ITargetBlock<TOutput>)
Releases a previous message reservation on the source block.
public virtual void ReleaseReservation(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target)
Parameters
messageHeaderDataflowMessageHeaderThe header of the message reservation being released.
targetITargetBlock<TOutput>The target block that held the reservation.
ReserveMessage(DataflowMessageHeader, ITargetBlock<TOutput>)
Reserves a message previously offered by the source block.
public virtual bool ReserveMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target)
Parameters
messageHeaderDataflowMessageHeaderThe header of the message being reserved.
targetITargetBlock<TOutput>The target block attempting to reserve the message.