gNode-Client

gNode Client Implementation Keynotes

Architecture primer for implementing a client of the gNode daemon. The precise wire contract is CONTRACT.md; the command catalogue is gNode COMMAND_SCHEMA.md.

Key Stream Connection Pattern

{site_id}:gnode:unified:{environment}    # Unified command stream (client → daemon)
{site_id}:res:{request_id}               # Per-request response key (daemon → client, polled)

Braces around site_id are literal (Redis Cluster hash-tag routing). The unified stream is per-DTAP-environment (testing|staging|acceptance|production), not per-node (gNodeClient::getComputeStream). The health stream is {site_id}:gnode:health.

Multi-Node Architecture

Security Model

Command Format

Commands travel as XADD fields with canonical short names and full command names (gNodeClient::sendCommand):

{
  "t": "c",                        // Type: command
  "id": "example.com:6864...",     // Request id (uniqid, site-prefixed)
  "c": "geometric_discover",       // Full command name (no abbreviation on the wire)
  "p": "{\"layer\":\"3\",\"facets\":{...},\"_request_id\":\"...\"}", // JSON-encoded params
  "ss": "example.com",             // Source site
  "sn": "client",                  // Source node
  "ts": "1751500000000"            // Unix timestamp, whole MILLISECONDS
}

Long-form aliases (command, params, site_id, ...) are accepted daemon-side (gNode daemon/src/utils.rs::field_names) but this client always emits the short forms.

Response Format

The daemon writes the response JSON to the per-request response key; the client polls it via FCALL GNODE_CACHE_GET with exponential backoff (gNodeClient::pollForResponse):

{
  "status": "ok",              // "ok" or "error"
  "result": {},                // Result data (present on success)
  "error": null                // Error message (present on failure)
}

Command Processing Flow

  1. Client XADDs command to the unified stream
  2. Daemon reads command via consumer group gnode-daemon
  3. Daemon routes the command to its handler
  4. Daemon writes the response to {site_id}:res:{request_id}
  5. Client polls the response key until hit or timeout (default 5 s, timeout config key)

Fallback

The client is FCALL-first. When the daemon or ValKey is unreachable, an optional Fallback\FallbackHandler executes the supported commands locally (degraded mode); the first poll timeout sets a sticky daemon-unreachable flag so later commands in the request fail fast.

Batch Processing

Design Principles