13#include <unordered_map>
17#include <dfx-core/messages/DataMessage.hpp>
19#include <dfx-subprocess/Process.hpp>
21#include <dfx-utilities/FileSystem.hpp>
22#include <dfx-utilities/MonotonicIdAllocator.hpp>
31 struct JsonParserState
33 bool hasEmitWarnForFirstNonValidChar =
false;
34 char openDelimiter =
'\0';
35 char closeDelimiter =
'\0';
47 std::string stdoutData;
48 std::string stderrData;
50 JsonParserState stdoutParserState;
51 JsonParserState stderrParserState;
54 using ChildInfos = std::unordered_map<uint32_t, ChildInfo>;
76 EmitMode emitMode = EmitMode::Line;
80 Process(
Id id, std::string
name);
91 ChildInfos::iterator _startNewChild();
93 void _sendMessageToChild(ChildInfo & childInfo,
Core::DataMessage const & message);
95 void _onStdoutReadyRead(uint32_t
id, std::string data);
96 void _onStderrReadyRead(uint32_t
id, std::string data);
97 void _onChildTerminated(uint32_t
id);
104 LifeCycle _lifecycle;
105 bool _shouldRestart =
true;
107 std::chrono::milliseconds _stopTimeout{0};
109 std::queue<Core::MessagePtr> _stdinBuffer;
115 ChildInfos _childInfos;
Macro-based enum <-> string utilities for dfx.
#define DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
Event interest and trigger flags for file-descriptor watching (Linux/epoll).
Base class for all runtime-executed nodes in a dfx dataflow graph.
#define DFX_NODE(typeName)
Convenience macro to declare the node type string and metadata/schema hooks.
Definition Node.hpp:501
Data-plane message containing an owned byte buffer.
Definition DataMessage.hpp:42
Abstract base class for all nodes in the dfx runtime.
Definition Node.hpp:91
uint32_t Id
Node identifier type (unique and stable within a graph instance).
Definition Node.hpp:113
FdWatch::Poller & poller()
Access a poller instance associated with this node.
nlohmann::json const & config() const noexcept
Get the node configuration.
Definition Node.hpp:138
std::string const & name() const noexcept
Get the node name.
Definition Node.hpp:134
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
void initializeImpl(nlohmann::json config) override
Called by initialize; derived nodes must parse config here.
void startImpl() override
Called by start before the node is marked running.
void handleMessage(Core::InputPort const &port, Core::MessagePtr message) override
Handle an incoming message on an input port.
void stopImpl() override
Called by stop before the node is marked stopped.
Subprocess wrapper with optional stdio piping/capture and event-driven callbacks.
Definition Process.hpp:59
Which
Identifies which standard stream is being referred to.
Definition Process.hpp:87
Monotonically increasing ID allocator.
Definition MonotonicIdAllocator.hpp:52
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27
Definition MimeTypeRouter.hpp:18
Definition Process.hpp:75
Process spawn and I/O configuration.
Definition Process.hpp:123