Memco

Class Memco

A connection to Memco Shared Memory.

Constructing one resolves settings and opens a channel but sends nothing. Memco.connect runs the two checks that prove the connection works — and, with a token, teaches the client the limits the service enforces on the way, which is what lets later calls refuse an over-long field before spending a round trip on it. Nothing else runs them: a client is not awaitable, so await using client = new Memco(...) opens no connection at all — the await in the example below belongs to Memco.connect, and using only closes.

A client built from an API client's clientId and clientSecret exchanges them for a token, and renews it before it expires. Such a token carries no content role of its own, so the service refuses memory calls made with it: that client administers Memco.networks and Memco.users, and reaches memory through sessions acting for your users — MemoryOperations.startSession with an externalId.

import { Memco } from '@memco/memcoai'

await using client = await new Memco().connect() // reads MEMCO_API_TOKEN
const { domains } = await client.memory.listDomains()
Index
  • Parameters

    • options: MemcoOptions = {}

      Credential, endpoint and per-call deadline, each falling back to the environment where one supplies it and then to a built-in default.

    Returns Memco

    MemcoConfigError If no credential is available, if a token is passed beside client credentials, if only half of the client pair is available, if tokenLifetime is given without client credentials or is not a positive whole number, if the host is blank or carries an invalid port, if MEMCO_API_TLS is neither true nor false, or if the timeout is not positive.

The memory operations.

The network administration: networks, their members and their groups. Needs an API client's credentials.

The user administration: external users and their API keys. Needs an API client's credentials.

credentialKind: "token" | "apiClient"

Which credential the client resolved from its options and the environment: token for an API token, apiClient for an API client's clientId and clientSecret. Only an API client can administer networks and users, or open a session acting as one of your users.

  • Verify the connection.

    Probes the health endpoint, then proves the credential. With a token that is MemoryOperations.listDomains, which also records the limits the service enforces. With client credentials it is the exchange for a token, and no memory method is called, since an issued token carries no content role. Safe to call more than once; it repeats both, except that a token already issued is reused until it is due for renewal.

    Returns Promise<Memco>

    This client.

    MemcoUnavailableError If the service cannot be reached.

    MemcoUnhealthyError If it answers but is not serving.

    MemcoAuthenticationError If the credential is rejected.

    MemcoSunsetError If what this client uses is past its sunset date.

    MemcoConfigError If the client has been closed.

  • Close the client.

    Waits for calls already in flight rather than cancelling them, then ends the keys of sessions acting for your users that are still live — no key is ended under a call still using it — and then releases the connection. Safe to call more than once, and never throws: a key that cannot be ended is logged by its id at WARNING, and expires on its own. Any call made afterwards throws MemcoConfigError, and closing a session changes nothing.

    Returns Promise<void>

  • Close the client at the end of an await using block.

    Returns Promise<void>

    When the channel is closed.

  • Report which version of the contract this SDK was generated from.

    Returns Provenance

    The provenance recorded when this package was built.

    client.provenance().serverCommit  // the commit this package was built from
    

On this page