Skip to Content

Interface MemcoOptions

Settings for a Memco, every one of them optional.

An argument always wins over the environment, and the environment over the built-in default. Three settings have an environment variable behind them: token reads MEMCO_API_TOKEN — falling back to the deprecated MEMCO_API_KEY, which warns — host reads MEMCO_API_HOST, and logLevel reads MEMCO_LOG. The rest fall straight through to their built-in values — TLS on, and DEFAULT_TIMEOUT seconds as the deadline every call inherits. The credential is the one connection setting with no default at all: a client that finds none is refused rather than left to fail on its first call.

All of it is resolved by the constructor, before a socket is opened, so a blank host, an unparseable port or a timeout that is not a positive number is a MemcoConfigError out of new Memco(...) rather than a transport failure later on.

MemcoOptions.logLevel is the odd one out: everything else here configures this client, and that configures the process.

interface MemcoOptions {
    logLevel?: string;
    token?: string;
    host?: string;
    tls?: boolean;
    timeout?: number;
    env?: Readonly<Record<string, string | undefined>>;
}

Hierarchy

  • ResolveOptions
    • MemcoOptions
Index
logLevel?: string

Log level to apply before anything else happens, one of critical, error, warning, info, debug, or none to silence the SDK.

Setting it is process-wide, because a logger is. Prefer the MEMCO_LOG environment variable in an application that has its own logging: it says the same thing without a library reaching into global state on the application's behalf.

MemcoConfigError If it does not name a level. A bad MEMCO_LOG warns and falls back; a bad argument here is the caller's own code.

token?: string

Credential to authenticate with. When omitted, MEMCO_API_TOKEN is used, falling back to the deprecated MEMCO_API_KEY with a warning. A blank value is refused rather than treated as absent.

host?: string

Service endpoint, optionally including a port such as localhost:50051 or [2001:db8::1]:50051. When omitted, MEMCO_API_HOST is used, falling back to DEFAULT_HOST. A host without a port gets DEFAULT_PORT. A blank value is refused rather than treated as absent.

tls?: boolean

Whether to dial over TLS with the system trust store. Set to false only for a plaintext endpoint, such as a local server.

timeout?: number

Default per-call deadline in seconds.

env?: Readonly<Record<string, string | undefined>>

Environment to read from. Defaults to process.env; supplying one is mainly useful in tests.