Mads
Multi-Agent Distributed System
Loading...
Searching...
No Matches
broker_probe.hpp
Go to the documentation of this file.
1/*
2 ____ _
3 | __ ) _ __ ___ | | _____ _ __
4 | _ \| '__/ _ \| |/ / _ \ '__|
5 | |_) | | | (_) | < __/ |
6 |____/|_| \___/|_|\_\___|_|
7 ____ _
8 | _ \ _ __ ___ | |__ ___
9 | |_) | '__/ _ \| '_ \ / _ \
10 | __/| | | (_) | |_) | __/
11 |_| |_| \___/|_.__/ \___|
12
13Small, dependency-light readiness probes shared by `mads up`'s
14`ready = "broker" | "port:<n>"` and (later, on a different branch) by
15`mads doctor`'s broker-reachability check. Kept outside agent.hpp/.cpp on
16purpose: neither probe needs a full Mads::Agent.
17
18Author(s): Paolo Bosetti
19*/
20#ifndef MADS_BROKER_PROBE_HPP
21#define MADS_BROKER_PROBE_HPP
22
23#include <chrono>
24#include <filesystem>
25#include <map>
26#include <optional>
27#include <string>
28
29namespace Mads {
30
45 std::filesystem::path key_dir;
46 std::string client_key_name = "client";
47 std::string server_key_name = "broker";
48};
49
66bool probe_broker(const std::string &uri, std::chrono::milliseconds timeout,
67 const std::optional<ProbeCurveKeys> &curve = std::nullopt);
68
81bool probe_tcp_port(const std::string &host, int port,
82 std::chrono::milliseconds timeout);
83
89
108probe_curve_handshake(const std::string &uri,
109 const std::filesystem::path &key_dir,
110 const std::string &client_key_name,
111 const std::string &server_key_name,
112 std::chrono::milliseconds timeout);
113
140std::optional<std::map<std::string, int>>
141fetch_subscription_table(const std::string &sub_uri,
142 std::chrono::milliseconds timeout,
143 const std::optional<ProbeCurveKeys> &curve = std::nullopt);
144
145} // namespace Mads
146
147#endif // MADS_BROKER_PROBE_HPP
Definition agent.hpp:67
bool 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 ...
bool 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 tim...
CurveProbeResult 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_...
std::optional< std::map< std::string, int > > 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 = tr...
Client-side CURVE credentials for a probe socket: the same key_dir/client/server naming convention ev...
std::string client_key_name
std::filesystem::path key_dir
std::string server_key_name