dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Core::Channel Class Reference

Orchestrator connecting a source transport to a destination transport. More...

#include <dfx-core/Channel.hpp>

Public Types

using Id = uint32_t
 Identifier type (unique within a graph instance, by convention).

Public Member Functions

 Channel (Id id, SourceTransportPtr source, DestinationTransportPtr destination)
 Construct a channel linking one input port to one output port.
 DFX_DISABLE_COPY_AND_MOVE (Channel)
 Channel is not copiable nor movable.
Id id () const noexcept
 Get the channel id.
int64_t pendingMessageCount () const
 Return the number of pending message in this channel or -1 if unknown.
SourceTransportPtr const & source () const noexcept
 Get the source transport a.k.a. the OutputPort.
DestinationTransportPtr const & destination () const noexcept
 Get the destination transport a.k.a. the InputPort.
void setDeliveryHook (Hooks::Delivery *hook)
 Set the optional delivery hook for this channel.

Protected Member Functions

bool transmit (MessagePtr message)
 Transmits a message from the source transport to the destination transport.

Friends

class SourceTransport

Detailed Description

Orchestrator connecting a source transport to a destination transport.

A Channel represents a directed edge in the dataflow graph. Unlike a simple pipe, the Channel serves as the central "Engine" or "Hub" for message movement. It doesn't handle the physical I/O itself (that is delegated to Transports), but instead manages the lifecycle of a message as it moves from one process/node boundary to another.

Messaging Workflow
The channel workflow follows a strict "Hub-and-Spoke" model:
  1. Source: A dfx::Core::SourceTransport receives data (locally or from the wire) and invokes transmit().
  2. Orchestration: The Channel applies configured hooks (pre-delivery) to validate or filter the message.
  3. Destination: The Channel hands the message to a dfx::Core::DestinationTransport for final delivery (local queuing or remote transmission).
  4. Finalization: The Channel applies post-delivery hooks.
Ownership and Lifetime
The Channel owns both its SourceTransport and DestinationTransport. It is typically owned by the Graph::Controller. The Channel ensures that transports are correctly attached and initialized during its own construction.
Constraints
See also
SourceTransport, DestinationTransport

Member Typedef Documentation

◆ Id

using dfx::Core::Channel::Id = uint32_t

Identifier type (unique within a graph instance, by convention).

Constructor & Destructor Documentation

◆ Channel()

dfx::Core::Channel::Channel ( Id id,
SourceTransportPtr source,
DestinationTransportPtr destination )

Construct a channel linking one input port to one output port.

Parameters
idChannel id.
sourceThe source transport.
destinationThe destination transport.

Member Function Documentation

◆ destination()

DestinationTransportPtr const & dfx::Core::Channel::destination ( ) const
inlinenoexcept

Get the destination transport a.k.a. the InputPort.

◆ DFX_DISABLE_COPY_AND_MOVE()

dfx::Core::Channel::DFX_DISABLE_COPY_AND_MOVE ( Channel )

Channel is not copiable nor movable.

◆ id()

Id dfx::Core::Channel::id ( ) const
inlinenoexcept

Get the channel id.

◆ pendingMessageCount()

int64_t dfx::Core::Channel::pendingMessageCount ( ) const

Return the number of pending message in this channel or -1 if unknown.

◆ setDeliveryHook()

void dfx::Core::Channel::setDeliveryHook ( Hooks::Delivery * hook)
inline

Set the optional delivery hook for this channel.

The hook pointer is stored as-is; it is not owned by the channel. Concrete implementations may call the hook around enqueue/dequeue/delivery.

Parameters
hookHook pointer, or null to disable.

◆ source()

SourceTransportPtr const & dfx::Core::Channel::source ( ) const
inlinenoexcept

Get the source transport a.k.a. the OutputPort.

◆ transmit()

bool dfx::Core::Channel::transmit ( MessagePtr message)
protected

Transmits a message from the source transport to the destination transport.

This is the core orchestration method of the channel. It handles the entire internal delivery pipeline, including hook execution and final delivery to the destination transport. The transmission follows a strict sequence:

  1. Pre-Delivery Hook: If a Hooks::Delivery is set, preDelivery is invoked. If the hook returns Skip or Fail, the message is dropped and this method returns immediately.
  2. Destination Delivery: The message is handed to the DestinationTransport::deliver method.
  • For local destinations, this pushes to a details::SyncQueue.
  • For remote destinations, this packs and sends the message over the wire.
  1. Post-Delivery Hook: If delivery was successful, the postDelivery hook is executed.
Note
This method is called by SourceTransport::transmitMessage when the SourceTransport has a message ready for the channel.
Parameters
messageThe message to be transmitted. Must not be null.
Returns
true if the message was successfully processed and accepted by the destination transport; false if the message was rejected (e.g., hook failure or full destination queue).
Exceptions
dfx::Utils::ExceptionIf the message is null.

The documentation for this class was generated from the following file: