Selva Compute API Reference - v2.1.0
    Preparing search index...

    Class ComputeServerStats

    ComputeServerStats provides methods to query Rhino Compute server statistics.

    Use this for server health monitoring and statistics.

    const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');

    try {
    const isOnline = await stats.isServerOnline();
    const children = await stats.getActiveChildren();
    const version = await stats.getVersion();

    // Or get everything at once
    const allStats = await stats.getServerStats();
    } finally {
    await stats.dispose(); // Clean up resources
    }
    Index

    Constructors

    Methods

    • Get the number of active child processes on the server.

      Returns Promise<number | null>

      Number of active children, or null if unavailable

    • Get comprehensive server statistics. Fetches all available server information in parallel.

      Returns Promise<
          {
              activeChildren?: number;
              isOnline: boolean;
              version?: { compute: string; git_sha: string
              | null; rhino: string };
          },
      >

      Object containing server status and available stats

    • Get the server version information.

      Returns Promise<{ compute: string; git_sha: string | null; rhino: string } | null>

      Version object with rhino, compute, and git_sha, or null if unavailable

    • Check if the server is online.

      This is a single-sample probe: it returns true only on a 2xx from /healthcheck, and false for every other outcome (non-2xx, network error, or timeout). A cold or briefly-busy-but-up server can therefore read as offline — callers that gate on this (e.g. client construction) should retry rather than treat a single false as authoritative.

      Parameters

      • timeoutMs: number = 5000

        Abort the probe after this many ms (default: 5000). Pass 0 to disable the timeout. Prevents a hung connection from stalling the caller indefinitely.

      Returns Promise<boolean>

    • Continuously monitor server stats at specified interval.

      Parameters

      • callback: (
            stats: {
                activeChildren?: number;
                isOnline: boolean;
                version?: { compute: string; git_sha: string | null; rhino: string };
            },
        ) => void

        Function called with stats on each interval

      • intervalMs: number = 5000

        Milliseconds between checks (default: 5000)

      Returns () => void

      Function to stop monitoring

      const stopMonitoring = stats.monitor((data) => {
      console.log('Server stats:', data);
      }, 3000);

      // Later...
      stopMonitoring();
    • Purge the server's solve-results / URL-data cache.

      POSTs to cache/purge and returns the number of entries removed, or null if the request failed. This clears cached solve responses and fetched definition-URL data; it does NOT evict the definition cache (active pointer references stay valid).

      Caveat: cache/purge is forwarded by the rhino.compute proxy to a single round-robin-selected child, so in a multi-child deployment one call purges one child's cache. Call repeatedly (or size the pool to 1) if you need a fleet-wide purge.

      Returns Promise<number | null>

      Number of entries removed, or null on failure.

      const removed = await stats.purgeCache();
      if (removed !== null) console.log(`Purged ${removed} cached solves`);