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

    Class GrasshopperClient

    GrasshopperClient provides a simple API for interacting with a Rhino Compute server and grasshopper.

    This is the recommended high-level API for Rhino Compute operations.

    Security Warning: Using this client in a browser environment exposes your server URL and API key to users. For production, use this library server-side or proxy requests through your own backend.

    const client = await GrasshopperClient.create({
    serverUrl: 'http://localhost:6500',
    apiKey: 'your-api-key'
    });

    try {
    const result = await client.solve(definitionUrl, { x: 1, y: 2 });
    } finally {
    await client.dispose(); // Clean up resources
    }
    Index

    Properties

    serverStats: ComputeServerStats

    Methods

    • Create a scheduler bound to this client. Use a scheduler for any UI surface that fires solves frequently (sliders, live editors) or that needs cancel semantics, response caching, or state observability.

      Multiple schedulers can be created from a single client — typically one per UI surface so their queues stay independent.

      Parameters

      Returns SolveScheduler

      const sliderScheduler = client.createScheduler({ mode: 'latest-wins' });
      const submitScheduler = client.createScheduler({ mode: 'queue', timeoutMs: 0, retry: { attempts: 1 } });
    • Creates and initializes a GrasshopperClient with server validation.

      The pre-flight /healthcheck probe is a single-sample boolean gate that reads a cold or briefly-busy-but-up server as offline. To avoid failing construction on that transient class, the probe is retried with a short exponential backoff before giving up. Each probe is also bounded by a timeout so a hung connection can't stall construction.

      Parameters

      Returns Promise<GrasshopperClient>

      with code NETWORK_ERROR if the server stays unreachable across all attempts

      with code INVALID_CONFIG if configuration is invalid