import type { IncomingMessage, ServerResponse } from "node:http"; import type { ThingD } from "@thingd/sdk"; export type ThingdClusterMode = "single" | "leader" | "follower"; export type ThingdClusterDiscovery = "none" | "static" | "kubernetes"; export type ThingdClusterOptions = { mode?: ThingdClusterMode; advertiseUrl?: string; leaderUrl?: string; fallbackLeaderUrl?: string; peers?: string[]; discovery?: ThingdClusterDiscovery; service?: string; namespace?: string; port?: number; forwardAuthToken?: string; statusPath?: string; peersPath?: string; /** Enable automatic leader failover. Default: false. */ leaderElection?: boolean; /** Consecutive replication failures before triggering election. Default: 3. */ electionMaxFailures?: number; }; export type ResolvedThingdClusterOptions = { mode: ThingdClusterMode; advertiseUrl?: string; leaderUrl?: string; fallbackLeaderUrl?: string; activeLeaderUrl?: string; peers: string[]; discovery: ThingdClusterDiscovery; service?: string; namespace?: string; port: number; forwardAuthToken?: string; statusPath: string; peersPath: string; leaderElection: boolean; electionMaxFailures: number; /** Cached replication lag (events behind leader). Updated by the replication runner. */ cachedReplicationLag: number; }; export type ThingdClusterStatus = { mode: ThingdClusterMode; writable: boolean; forwarding: boolean; leaderUrl?: string; fallbackLeaderUrl?: string; activeLeaderUrl?: string; advertiseUrl?: string; discovery: ThingdClusterDiscovery; peers: string[]; leaderElection: boolean; electionMaxFailures: number; consecutiveFailures: number; replication: { lastReplicatedSequence: number; status: string; lag?: number; } | "not-implemented"; }; export declare function readClusterOptionsFromEnv(env: Record): ThingdClusterOptions; export declare function resolveClusterOptions(options: ThingdClusterOptions | undefined): ResolvedThingdClusterOptions; export declare function getClusterStatus(cluster: ResolvedThingdClusterOptions, db: ThingD, consecutiveFailures?: number): Promise; export declare function forwardMcpRequestToLeader(cluster: ResolvedThingdClusterOptions, mcpPath: string, request: IncomingMessage, response: ServerResponse): Promise; export declare function findNextLeaderCandidate(cluster: ResolvedThingdClusterOptions): { url: string; isSelf: boolean; } | undefined; //# sourceMappingURL=cluster.d.ts.map