![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Control-plane message (command + params). More...
#include <dfx-core/messages/ControlMessage.hpp>
Public Member Functions | |
| int | version () const noexcept |
| Protocol version of this control message (default: 1). | |
| std::string const & | command () const noexcept |
| Command name carried by this message. | |
| nlohmann::json const & | params () const noexcept |
| JSON parameters carried by this message (may be null). | |
| nlohmann::json | toJson () const |
| Serialize this control message to JSON. | |
| Kind | kind () const override |
| This message belongs to the control-plane connectivity domain. | |
| MessagePtr | clone () const override |
| Clone this message (deep copy). | |
| Public Member Functions inherited from dfx::Core::Message | |
| DISABLE_COPY_AND_MOVE (Message) | |
| Messages are non-copyable and non-movable. | |
| virtual | ~Message () |
| Virtual destructor. | |
| template<typename Clock = std::chrono::steady_clock> requires std::chrono::is_clock_v<Clock> | |
| std::chrono::time_point< Clock, std::chrono::microseconds > | timestampToTimePoint () const noexcept |
| Convert timestamp() into a time_point of the given clock type. | |
| void | addToPathTaken (std::string path) |
| Append one hop to the message path trace. | |
| template<DerivedFromMessage T> | |
| bool | is () const noexcept |
| Check whether this message is of a given derived type. | |
| template<DerivedFromMessage T> | |
| T & | as () noexcept |
| Cast this message to a derived type (unchecked). | |
| template<DerivedFromMessage T> | |
| T const & | as () const noexcept |
| Cast this message to a derived type (unchecked). | |
| Utils::UUID const & | uuid () const noexcept |
| Unique identifier of this message instance. | |
| Utils::UUID const & | parentUuid () const noexcept |
| UUID of the parent message if created from one, otherwise default UUID value. | |
| std::vector< std::string > const & | pathTaken () const noexcept |
| Sequence of "node.port" hops this message has traversed. | |
| std::chrono::microseconds | timestamp () const noexcept |
| Construction timestamp in microseconds since timestampClock epoch. This is not "wall clock time" unless timestampClock is CLOCK_REALTIME. | |
| bool | hasMimeType () const noexcept |
| Whether the message carries an explicit MIME type. | |
| MimeType | mimeType () const noexcept |
| Get the message MIME type. If no explicit MIME type is set, returns dfx::Core::MimeType::OctetStream. | |
| void | setMimeType (MimeType mimeType) |
| Set the message MIME type. | |
| void | resetMimeType () |
| Clear the explicit MIME type (message then defaults to octet-stream). | |
Protected Member Functions | |
| void | cloneFromBase (Message const &base) override |
Copy base and derived state from base into this instance. | |
| ControlMessage (MessagePtr const &parent=nullptr) | |
| Construct an empty control message, optionally inheriting from a parent. | |
| ControlMessage (std::string command, nlohmann::json params={}, int version=1, MessagePtr const &parent=nullptr) | |
| Construct a control message with command, params and version. | |
| Protected Member Functions inherited from dfx::Core::Message | |
| Message (MessagePtr const &parent=nullptr) | |
| Construct a message, optionally inheriting state from a parent message. | |
| Message (MimeType mimeType, MessagePtr const &parent=nullptr) | |
| Construct a message with an explicit MIME type, optionally inheriting from a parent. | |
Friends | |
| class | Message |
Additional Inherited Members | |
| Static Public Member Functions inherited from dfx::Core::Message | |
| template<DerivedFromMessage T, typename ... Args> | |
| static std::unique_ptr< T > | create (Args &&... args) |
| Convenience allocator for derived message types. | |
| Static Public Attributes inherited from dfx::Core::Message | |
| static clockid_t | timestampClock |
| Clock used by the constructor to capture timestamps. | |
Control-plane message (command + params).
This makes control messages unambiguous on the wire and allows ports/runtime to treat them separately from data-plane payloads.
If the stored params value is JSON null, toJson() normalizes it to an empty JSON object ({}) in the output.
|
protected |
Construct an empty control message, optionally inheriting from a parent.
The base constructor always sets the MIME type to MimeType::DfxControl.
| parent | Optional parent message whose UUID is inherited. |
|
protected |
Construct a control message with command, params and version.
The base constructor always sets the MIME type to MimeType::DfxControl.
| command | Command name. |
| params | JSON parameters (moved into the message). |
| version | Protocol version (default: 1). |
| parent | Optional parent message whose UUID is inherited. |
|
overridevirtual |
Clone this message (deep copy).
The clone copies the base state and duplicates the version, command and params JSON.
Implements dfx::Core::Message.
|
overrideprotectedvirtual |
Copy base and derived state from base into this instance.
Copies the base fields via Message::cloneFromBase(base) then copies:
Reimplemented from dfx::Core::Message.
|
inlinenoexcept |
Command name carried by this message.
|
inlineoverridevirtual |
This message belongs to the control-plane connectivity domain.
Implements dfx::Core::Message.
|
inlinenoexcept |
JSON parameters carried by this message (may be null).
| nlohmann::json dfx::Core::ControlMessage::toJson | ( | ) | const |
Serialize this control message to JSON.
If params() is null, this returns an empty object for "params".
Output format:
|
inlinenoexcept |
Protocol version of this control message (default: 1).