Plugins

Covers Engine Plugin SDK 2.0.0 · Interface Plugin SDK 0.2.0

ZmqPeerHub

Reuse an engine server ROUTER/PUB and own one shared SUB plus one DEALER per logical peer connection.

API

Reuse an engine server ROUTER/PUB and own one shared SUB plus one DEALER per logical peer connection.

Namespace: TEMPEST.

#include <tempest/ZmqPeer.h>

Declaration

class ZmqPeerHub {
public:
    struct Config {
        std::string operations_endpoint;
        std::string telemetry_endpoint;
        std::string password;
        std::size_t max_peers = 128;
        std::size_t max_queued_messages = 4096;
    };
    using AcceptHandler = std::function<void(TransportPtr, PeerDeclaration)>;
    using RouterSender = std::function<void(std::string identity, std::string wire)>;
    using Publisher = std::function<void(std::string topic, std::string wire)>;
    ZmqPeerHub(Config config, RouterSender router, Publisher publisher, AcceptHandler accept);
    ~ZmqPeerHub();
    void start();
    void stop();
    bool receive(std::string identity, std::string wire);
    TransportPtr connect(ZmqPeerConfig config);
    nlohmann::json diagnostics() const;
};