build: opt-out WITH_MQTT/WITH_REDIS flags + extend Redis to /status parity
- Add CMake options WITH_MQTT (default ON) and WITH_REDIS (default ON).
When OFF, the matching .cpp is dropped from the target, the pkg_check
is skipped, and MqttPublisher.h / RedisStore.h expose no-op stub
classes so every call site in Reflector.cpp / ReflectorClient.cpp /
TrunkLink.cpp keeps compiling. svxreflector.cpp's --import-conf-to-redis
is gated on WITH_REDIS. Lets sysops who don't run MQTT or Redis drop
libmosquitto-dev / libhiredis-dev from their build environment.
README.md and docs/INSTALL.md document the flags.
- Fill the gap between /status and Redis with three new event-driven
keys (all small, all using the existing 60s TTL refresh):
* live:meta — mode, version, local_prefix, listen_port, http_port,
cluster_tgs, satellite-server stats. Written at startup, on
reloadClusterTgs(), and on satellite connect/disconnect.
* live📡<sat_id> — per-satellite status blob. Written via
a new SatelliteLink::statusChanged signal on hello + on every
talker start/stop. Cleared on disconnect / cleanup.
* live:trunk:<section>.status — extended trunk hash with the full
TrunkLink::statusJson() snapshot. Written at startup, on trunk
state changes, and on config.changed-all reloads.
A dashboard can now reconstruct the equivalent of GET /status from a
handful of small Redis keys instead of one ~500 KB blob — idiomatic
Redis usage, no per-second hot-write churn.
- New Redis tests: live_meta_populated_at_startup,
live_trunk_carries_status_blob.
All four flag combinations build cleanly. 31 trunk + 10 twin + 16 redis
pass.
This commit is contained in:
1 parent
688a62ec5b
commit
bd196d6365
13 files changed
+447
-19
No files matched your search
@@ -7,10 +7,12 @@
|
||||
#include <json/json.h>
|
||||
#include "ReflectorMsg.h"
|
||||
|
||||
struct mosquitto;
|
||||
|
||||
namespace Async { class Config; }
|
||||
|
||||
#ifdef WITH_MQTT
|
||||
|
||||
struct mosquitto;
|
||||
|
||||
class MqttPublisher
|
||||
{
|
||||
public:
|
||||
@@ -67,4 +69,35 @@ class MqttPublisher
|
||||
|
||||
}; /* class MqttPublisher */
|
||||
|
||||
#else /* !WITH_MQTT */
|
||||
|
||||
// Build-time no-op stub: lets the rest of the codebase compile and link
|
||||
// when libmosquitto is unavailable. initialize() returns false so
|
||||
// Reflector::initialize logs the existing "MQTT publisher failed to
|
||||
// initialize, continuing without MQTT" warning and proceeds with
|
||||
// m_mqtt = nullptr; every other call site is already null-guarded.
|
||||
class MqttPublisher
|
||||
{
|
||||
public:
|
||||
MqttPublisher(Async::Config&) {}
|
||||
bool initialize(void) { return false; }
|
||||
void shutdown(void) {}
|
||||
void onTalkerStart(uint32_t, const std::string&, bool) {}
|
||||
void onTalkerStop(uint32_t, const std::string&, bool) {}
|
||||
void onClientConnected(const std::string&, uint32_t,
|
||||
const std::string&) {}
|
||||
void onClientDisconnected(const std::string&) {}
|
||||
void onTrunkUp(const std::string&, const std::string&,
|
||||
const std::string&, uint16_t) {}
|
||||
void onTrunkDown(const std::string&, const std::string&) {}
|
||||
void onRxUpdate(const std::string&, const Json::Value&) {}
|
||||
void publishFullStatus(const Json::Value&) {}
|
||||
void publishLocalNodes(
|
||||
const std::vector<MsgTrunkNodeList::NodeEntry>&) {}
|
||||
void publishPeerNodes(const std::string&,
|
||||
const std::vector<MsgTrunkNodeList::NodeEntry>&) {}
|
||||
};
|
||||
|
||||
#endif /* WITH_MQTT */
|
||||
|
||||
#endif /* MQTT_PUBLISHER_INCLUDED */
|
||||
Reference in new issue
Block a user