dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Hooks::Port Class Referenceabstract

Port-level message observation hook. More...

#include <dfx-hooks/Port.hpp>

Inheritance diagram for dfx::Hooks::Port:
[legend]

Public Member Functions

virtual void onMessageSent (Core::OutputPort const &port, Core::Message const &message)=0
 Called when a message is sent through an output port.
virtual void onMessageReceived (Core::InputPort const &port, Core::Message const &message)=0
 Called when a message is received through an input port.

Detailed Description

Port-level message observation hook.

Port hooks are invoked on every message observed at the port boundary:

This is intentionally separate from dfx::Hooks::Delivery:

  • Delivery hooks are channel/enqueue oriented (e.g., Channel::pushMessage()) and take descisions.
  • Port hooks are port oriented and are called whenever a message crosses a port, regardless of the underlying transport/channel type. And they are observers only.
Exception handling
Implementations are called through dfx::Utils::safeInvoke(). Meaning that throwing from these callbacks will not stop message flow and will not propagate to the caller.
Note
This hook is on a hot path: it can be invoked for every message. Keep implementations lightweight; offload expensive work to a queue/thread.
Warning
Threading and ordering are runtime-defined. Assume these callbacks may be invoked concurrently and that relative ordering between ports/messages may not be stable.

Member Function Documentation

◆ onMessageReceived()

virtual void dfx::Hooks::Port::onMessageReceived ( Core::InputPort const & port,
Core::Message const & message )
pure virtual

Called when a message is received through an input port.

This callback is invoked whenever a message crosses the input port boundary. This correspond to the moment the message is handed to the port.

Parameters
portThe input port receiving the message.
messageThe message being received.
Note
message is provided as a const reference: hooks must not mutate it. Any exception thrown by the hook is caught, logged, and discarded.

Implemented in dfx::Pcapng::Capture.

◆ onMessageSent()

virtual void dfx::Hooks::Port::onMessageSent ( Core::OutputPort const & port,
Core::Message const & message )
pure virtual

Called when a message is sent through an output port.

This callback is invoked whenever a message passes through the output port boundary. It does not imply anything about when or whether the destination will consume the message (that depends on the channel/runtime mechanics).

Parameters
portThe output port sending the message.
messageThe message being sent.
Note
message is provided as a const reference: hooks must not mutate it. Any exception thrown by the hook is caught, logged, and discarded.

Implemented in dfx::Pcapng::Capture.


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