@oxia-db/client - v0.1.0
    Preparing search index...

    Class OxiaClient

    Asynchronous client for the Oxia service.

    Build one with OxiaClient.connect. Call OxiaClient.close when done to release the gRPC channels, stop the background shard-assignment watcher, and cleanly tear down any open sessions.

    The client is safe to use from multiple async contexts — every method is non-blocking and internally dispatches to the appropriate shard leader.

    const client = await OxiaClient.connect('localhost:6648');
    try {
    await client.put('/users/alice', 'hello');
    const r = await client.get('/users/alice');
    console.log(new TextDecoder().decode(r.value));
    } finally {
    await client.close();
    }
    Index

    Methods

    • Connect to an Oxia service and wait for the initial shard assignments to arrive before returning.

      Parameters

      • serviceAddress: string

        host:port of any Oxia server. The client uses this address only to discover shard assignments; subsequent requests go directly to each shard's leader.

      • options: OxiaClientOptions = {}

      Returns Promise<OxiaClient>

      If the initial shard-assignment fetch does not complete within initTimeoutMs.

    • Associate a value with a key.

      Parameters

      Returns Promise<PutResult>

      The final key and version metadata for the written record.

      UnexpectedVersionIdError if expectedVersionId mismatches the server's current version.

      SessionNotFoundError for an ephemeral put when the client's session on the target shard no longer exists server-side.

      InvalidOptionsError for incompatible option combinations (e.g. sequenceKeysDeltas without partitionKey).

    • Delete the record stored at key.

      Parameters

      Returns Promise<boolean>

      true if a record existed and was removed, false if no record was found at that key (or at that key within the target partition).

      UnexpectedVersionIdError if expectedVersionId mismatches the server's current version.

    • Delete every record whose key falls in [minKeyInclusive, maxKeyExclusive).

      Without a partitionKey the operation is fanned out to every shard; with one it targets a single shard.

      Bounds are interpreted in Oxia's hierarchical key order — see https://oxia-db.github.io/docs/features/oxia-key-sorting

      Parameters

      Returns Promise<void>

    • Retrieve the record for a key.

      With the default EQUAL comparison this is an exact-match lookup on a single shard. With any other ComparisonType — or with useIndex — the client fans out to every shard and picks the best match in hierarchical key order.

      Parameters

      • key: string

        The key to look up. When useIndex is set, this is treated as a secondary key for that index.

      • opts: GetOptions = {}

      Returns Promise<GetResult>

      The matched record (primary key, value, and version).

      KeyNotFoundError if no record matches.

    • List every key in [minKeyInclusive, maxKeyExclusive).

      Without a partitionKey, each shard is queried in parallel and the results are merged. Keys are returned in Oxia's hierarchical sort order — see https://oxia-db.github.io/docs/features/oxia-key-sorting

      Use OxiaClient.rangeScan if you also need the values.

      Parameters

      • minKeyInclusive: string

        Start of the range (inclusive).

      • maxKeyExclusive: string

        End of the range (exclusive).

      • opts: ListOptions = {}

      Returns Promise<string[]>

      Sorted keys in the range, or [] if none match.

    • Stream records in [minKeyInclusive, maxKeyExclusive) as an AsyncIterable<GetResult>.

      Without a partitionKey, one streaming RPC is opened per shard and the results are merged in hierarchical key order. Break out of the for await (...) loop to cancel the remaining server streams.

      Use OxiaClient.list if you only need the keys (cheaper).

      Parameters

      Returns AsyncIterable<GetResult>

    • Release all resources held by the client: close any open sessions (triggering server-side removal of this client's ephemerals), stop the shard-assignment watcher, and close every gRPC channel.

      Idempotent. Any subsequent client call throws OxiaError.

      Returns Promise<void>