ZeroTierOne/nonfree/controller/PubSubWriter.hpp
Grant Limberg 6113bad61e
Some checks failed
/ build_macos (push) Has been cancelled
/ build_windows (push) Has been cancelled
/ Central Controller Build (push) Has been cancelled
/ build_ubuntu (push) Has been cancelled
/ multi-arch-docker (push) Has been cancelled
make pubsub topics configurable
Also for pubsub trips back to CV1/CV2, rather than having 2 queues for each service (networks & members), theres now only a single queue for each change type, and `frontend = (cv1|cv2)` attribute is set on the message for filtering.
2025-09-18 09:33:04 -07:00

45 lines
No EOL
1.1 KiB
C++

#ifndef ZT_CONTROLLER_PUBSUBWRITER_HPP
#define ZT_CONTROLLER_PUBSUBWRITER_HPP
#include <google/cloud/pubsub/publisher.h>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
namespace ZeroTier {
class PubSubWriter {
public:
PubSubWriter(std::string project, std::string topic, std::string controller_id);
virtual ~PubSubWriter();
bool publishNetworkChange(
const nlohmann::json& oldNetwork,
const nlohmann::json& newNetwork,
const std::string& frontend);
bool
publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember, const std::string& frontend);
bool publishStatusChange(
std::string frontend,
std::string network_id,
std::string node_id,
std::string os,
std::string arch,
std::string version,
int64_t last_seen);
protected:
bool publishMessage(const std::string& payload, const std::string& frontend);
private:
std::string _controller_id;
std::string _project;
std::string _topic;
std::shared_ptr<google::cloud::pubsub::Publisher> _publisher;
};
} // namespace ZeroTier
#endif // ZT_CONTROLLER_PUBSUBWRITER_HPP