Commit 89e912a5 authored by jan.koester's avatar jan.koester
Browse files

test

parent f53c3cd8
Loading
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -660,6 +660,27 @@ namespace authdb {
            json_object_put(jobj);
        }

        /* ---- JSON API: Cluster Sync ---- */
        void apiClusterSync(libhttppp::HttpRequest &curreq) {
            json_object *jobj = json_object_new_object();

            if (!g_Cluster || !g_Cluster->isRunning()) {
                json_object_object_add(jobj, "status", json_object_new_string("error"));
                json_object_object_add(jobj, "message", json_object_new_string("cluster not running"));
                sendJson(curreq, jobj);
                json_object_put(jobj);
                return;
            }

            g_Cluster->forceSync();

            json_object_object_add(jobj, "status", json_object_new_string("ok"));
            json_object_object_add(jobj, "epoch", json_object_new_int64(
                static_cast<int64_t>(g_Cluster->getRecoveryEpoch())));
            sendJson(curreq, jobj);
            json_object_put(jobj);
        }

        /* ---- JSON API: List Domains ---- */
        void apiListDomains(libhttppp::HttpRequest &curreq) {
            json_object *jobj = json_object_new_object();
@@ -2089,6 +2110,8 @@ namespace authdb {
                        apiVacuum(curreq, domain);
                    } else if (strcmp(apiurl, "clusterstatus") == 0) {
                        apiClusterStatus(curreq);
                    } else if (strcmp(apiurl, "clustersync") == 0) {
                        apiClusterSync(curreq);
                    } else {
                        sendJsonError(curreq, "Unknown API endpoint", 404);
                    }
+3 −0
Original line number Diff line number Diff line
@@ -209,6 +209,9 @@ namespace authdb {
        // Incremented on cluster recovery — backends check this to force refresh
        uint64_t getRecoveryEpoch() const { return recovery_epoch_.load(); }

        // Force all domain backends to re-fetch from cluster on next access
        void forceSync() { recovery_epoch_.fetch_add(1); }

    private:
        ClusterConfig cfg_;
        std::atomic<bool> running_{false};