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:
Audric committed 2026-04-17 02:52:36 +02:00
1 parent 688a62ec5b
commit bd196d6365
13 files changed
+447 -19

No files matched your search

+8
View File
@@ -77,8 +77,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "version/SVXREFLECTOR.h"
#include "Reflector.h"
#ifdef WITH_REDIS
#include <hiredis/hiredis.h>
#include "RedisStore.h"
#endif
/****************************************************************************
@@ -146,6 +148,7 @@ namespace {
LogWriter logwriter;
};
#ifdef WITH_REDIS
static int import_to_redis = 0;
static int dry_run = 0;
@@ -350,6 +353,7 @@ static bool runImportConfToRedis(Async::Config& cfg, bool dry_run)
if (ctx) redisFree(ctx);
return true;
}
#endif /* WITH_REDIS */
/****************************************************************************
@@ -595,9 +599,11 @@ int main(int argc, const char *argv[])
stdin_watch->activity.connect(sigc::ptr_fun(&stdinHandler));
}
#ifdef WITH_REDIS
if (import_to_redis) {
return runImportConfToRedis(cfg, dry_run != 0) ? 0 : 1;
}
#endif
Reflector ref;
if (ref.initialize(cfg))
@@ -664,10 +670,12 @@ static void parse_arguments(int argc, const char **argv)
"Start " PROGRAM_NAME " as a daemon", NULL},
{"version", 0, POPT_ARG_NONE, &print_version, 0,
"Print the application version string", NULL},
#ifdef WITH_REDIS
{"import-conf-to-redis", 0, POPT_ARG_NONE, &import_to_redis, 0,
"Import [USERS]/[PASSWORDS] from .conf into Redis, then exit", NULL},
{"dry-run", 0, POPT_ARG_NONE, &dry_run, 0,
"With --import-conf-to-redis: print commands without executing", NULL},
#endif
{NULL, 0, 0, NULL, 0}
};
int err;