Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
broker_probe.hpp File Reference
#include <chrono>
#include <filesystem>
#include <map>
#include <optional>
#include <string>

Go to the source code of this file.

Classes

struct  Mads::ProbeCurveKeys
 Client-side CURVE credentials for a probe socket: the same key_dir/client/server naming convention every mads-* executable's –crypto/–keys_dir/–key_client/–key_broker flags configure (and that Mads::CurveAuth::setup_curve_client() reads). More...
 

Namespaces

namespace  Mads
 

Enumerations

enum class  Mads::CurveProbeResult { Mads::Connected , Mads::RejectedAuth , Mads::Timeout }
 

Functions

bool Mads::probe_broker (const std::string &uri, std::chrono::milliseconds timeout, const std::optional< ProbeCurveKeys > &curve=std::nullopt)
 Probes whether a MADS broker's settings endpoint is up and speaking the MADS wire protocol: connects a REQ socket to uri, sends [LIB_VERSION, "settings", <probe-name>] and waits up to timeout for any reply. Any protocol-shaped reply counts as success – this does not try to load or validate settings for a real agent, it only proves the broker is listening and answering. ZeroMQ's own TCP reconnect logic means a single bounded receive is enough to also cover "not up yet" within timeout.
 
bool Mads::probe_tcp_port (const std::string &host, int port, std::chrono::milliseconds timeout)
 Probes whether a local TCP port is accepting connections, retrying (short bounded attempts) until timeout elapses. Used by ready = "port:<n>".
 
CurveProbeResult Mads::probe_curve_handshake (const std::string &uri, const std::filesystem::path &key_dir, const std::string &client_key_name, const std::string &server_key_name, std::chrono::milliseconds timeout)
 Attempts a real CURVE handshake against uri, using the client and server keys Mads::CurveAuth::setup_curve_client() reads from key_dir (same file convention as mads doctor --crypto's key check). A Mads::SocketMonitor attached before connecting distinguishes a genuine ZMQ_EVENT_HANDSHAKE_FAILED_AUTH rejection from an unreachable broker or an unresponsive one, both of which previously looked identical – a timeout.
 
std::optional< std::map< std::string, int > > Mads::fetch_subscription_table (const std::string &sub_uri, std::chrono::milliseconds timeout, const std::optional< ProbeCurveKeys > &curve=std::nullopt)
 Reads one live subscription table off a broker that was started with [broker] subscription_table = true, by subscribing to the subscriptions topic exactly as any ordinary agent would.