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
@@ -8,9 +8,12 @@
|
||||
#include <set>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Async { class Config; class Timer; }
|
||||
|
||||
#ifdef WITH_REDIS
|
||||
|
||||
struct redisContext;
|
||||
struct redisAsyncContext;
|
||||
namespace Async { class Config; class Timer; }
|
||||
|
||||
class RedisAsyncAdapter;
|
||||
class RedisLiveQueue;
|
||||
@@ -83,6 +86,21 @@ class RedisStore : public sigc::trackable
|
||||
// field of the existing live:client:<callsign> hash.
|
||||
void pushClientStatus(const std::string& callsign,
|
||||
const std::string& status_json);
|
||||
// Reflector-wide meta: mode, version, prefixes, listen ports, cluster
|
||||
// TGs, satellite-server stats. Stored under live:meta as a hash;
|
||||
// written event-driven (startup + on cfg/satellite-count changes).
|
||||
void pushMeta(const std::vector<std::pair<std::string,std::string>>& fields);
|
||||
// Per-satellite status snapshot. Stored under live:satellite:<sat_id>
|
||||
// as a hash with a `status` JSON field. Written when the satellite
|
||||
// hello is received and on per-satellite events; cleared on disconnect.
|
||||
void pushSatelliteStatus(const std::string& sat_id,
|
||||
const std::string& status_json);
|
||||
void clearSatelliteStatus(const std::string& sat_id);
|
||||
// Extended per-trunk status (full TrunkLink::statusJson snapshot).
|
||||
// Stored as the `status` field on the existing live:trunk:<section>
|
||||
// hash. Written on trunk state-change events.
|
||||
void pushTrunkStatus(const std::string& section,
|
||||
const std::string& status_json);
|
||||
void pushLiveTrunk(const std::string& section,
|
||||
const std::string& state,
|
||||
const std::string& peer_id);
|
||||
@@ -128,4 +146,83 @@ class RedisStore : public sigc::trackable
|
||||
std::string channelName(void) const;
|
||||
};
|
||||
|
||||
#else /* !WITH_REDIS */
|
||||
|
||||
// Build-time no-op stub: lets the rest of the codebase compile and link
|
||||
// when libhiredis is unavailable. connect() returns false so
|
||||
// Reflector::initialize aborts startup if [REDIS] is configured —
|
||||
// matching the existing "Redis is unreachable" path. The load*
|
||||
// accessors return empty containers; the live-state pushes are no-ops.
|
||||
class RedisStore : public sigc::trackable
|
||||
{
|
||||
public:
|
||||
struct Config
|
||||
{
|
||||
std::string host;
|
||||
uint16_t port = 6379;
|
||||
std::string password;
|
||||
int db = 0;
|
||||
std::string key_prefix;
|
||||
std::string unix_socket;
|
||||
bool tls_enabled = false;
|
||||
std::string tls_ca_cert;
|
||||
std::string tls_client_cert;
|
||||
std::string tls_client_key;
|
||||
};
|
||||
|
||||
struct TrunkPeerConfig
|
||||
{
|
||||
std::string host;
|
||||
std::string port;
|
||||
std::string secret;
|
||||
std::string remote_prefix;
|
||||
std::string peer_id;
|
||||
};
|
||||
|
||||
explicit RedisStore(const Config&) {}
|
||||
|
||||
bool connect(void) { return false; }
|
||||
bool isReady(void) const { return false; }
|
||||
|
||||
sigc::signal<void, std::string> configChanged;
|
||||
|
||||
std::string lookupUserKey(const std::string&) { return {}; }
|
||||
std::map<std::string, std::string> loadAllUsers(void) { return {}; }
|
||||
bool isUserEnabled(const std::string&) { return false; }
|
||||
|
||||
std::set<uint32_t> loadClusterTgs(void) { return {}; }
|
||||
|
||||
std::string loadTrunkFilter(const std::string&,
|
||||
const std::string&) { return {}; }
|
||||
std::map<uint32_t, uint32_t> loadTrunkTgMap(const std::string&) {
|
||||
return {};
|
||||
}
|
||||
std::map<std::string, TrunkPeerConfig> loadTrunkPeers(void) {
|
||||
return {};
|
||||
}
|
||||
void publishConfigChanged(const std::string&) {}
|
||||
|
||||
void pushLiveTalker(uint32_t, const std::string&,
|
||||
const std::string&) {}
|
||||
void clearLiveTalker(uint32_t) {}
|
||||
void pushLiveClient(const std::string&, const std::string&,
|
||||
const std::string&, uint32_t) {}
|
||||
void clearLiveClient(const std::string&) {}
|
||||
void pushClientStatus(const std::string&, const std::string&) {}
|
||||
void pushMeta(const std::vector<std::pair<std::string,std::string>>&) {}
|
||||
void pushSatelliteStatus(const std::string&, const std::string&) {}
|
||||
void clearSatelliteStatus(const std::string&) {}
|
||||
void pushTrunkStatus(const std::string&, const std::string&) {}
|
||||
void pushLiveTrunk(const std::string&, const std::string&,
|
||||
const std::string&) {}
|
||||
void pushPeerNode(const std::string&, const std::string&, uint32_t,
|
||||
float, float, const std::string&) {}
|
||||
void clearPeerNode(const std::string&, const std::string&) {}
|
||||
|
||||
uint64_t droppedLiveWrites(void) const { return 0; }
|
||||
size_t liveQueueSize(void) const { return 0; }
|
||||
};
|
||||
|
||||
#endif /* WITH_REDIS */
|
||||
|
||||
#endif /* REDIS_STORE_INCLUDED */
|
||||
Reference in new issue
Block a user