Orchestrator connecting a source transport to a destination transport.
More...
#include <dfx-core/Channel.hpp>
|
| using | Id = uint32_t |
| | Identifier type (unique within a graph instance, by convention).
|
|
| bool | transmit (MessagePtr message) |
| | Transmits a message from the source transport to the destination transport.
|
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:
- Source: A dfx::Core::SourceTransport receives data (locally or from the wire) and invokes transmit().
- Orchestration: The Channel applies configured hooks (pre-delivery) to validate or filter the message.
- Destination: The Channel hands the message to a dfx::Core::DestinationTransport for final delivery (local queuing or remote transmission).
- 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
◆ Id
Identifier type (unique within a graph instance, by convention).
◆ Channel()
| dfx::Core::Channel::Channel |
( |
Id | id, |
|
|
SourceTransportPtr | source, |
|
|
DestinationTransportPtr | destination ) |
Construct a channel linking one input port to one output port.
- Parameters
-
| id | Channel id. |
| source | The source transport. |
| destination | The destination transport. |
◆ 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 |
◆ pendingMessageCount()
| int64_t dfx::Core::Channel::pendingMessageCount |
( |
| ) |
const |
Return the number of pending message in this channel or -1 if unknown.
◆ setDeliveryHook()
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
-
| hook | Hook pointer, or null to disable. |
◆ source()
◆ 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:
- 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.
- 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.
- 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
-
| message | The 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
-
The documentation for this class was generated from the following file: