Interface MemcoOptions
logLevel?: string;
token?: string;
clientId?: string;
clientSecret?: string;
tokenLifetime?: number;
host?: string;
tls?: boolean;
timeout?: number;
env?: Readonly<Record<string, string | undefined>>;
}
Hierarchy
- ResolveOptions
- MemcoOptions
Properties
OptionallogLevel
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.
Optionaltoken
Credential to authenticate with: a Memco API key or a session token. When
omitted, and the environment holds no client credentials,
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.
Passing it with ResolveOptions.clientId or
ResolveOptions.clientSecret is refused.
OptionalclientId
An API client's id, passed with ResolveOptions.clientSecret instead
of a token. The client exchanges the two for a token and renews it before
it expires. When neither they nor a token is passed, and both
MEMCO_CLIENT_ID and MEMCO_CLIENT_SECRET are set, those are used — even
if MEMCO_API_TOKEN is set too.
OptionalclientSecret
The API client's secret, passed with ResolveOptions.clientId. It is sent only to exchange for a token, and never logged.
OptionaltokenLifetime
Lifetime in seconds to ask for on each token issued for the client credentials. Omitted, the service's default applies. The service owns the maximum, and refuses a longer lifetime itself.
Optionalhost
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.
Optionaltls
Whether to dial over TLS with the system trust store. Set to false only
for a plaintext endpoint, such as a local server. When omitted,
MEMCO_API_TLS decides — true or false — falling back to true.
Optionaltimeout
Default per-call deadline in seconds.
Optionalenv
Environment to read from. Defaults to process.env; supplying one is
mainly useful in tests.
Settings for a Memco, every one of them optional.
An argument always wins over the environment, and the environment over the built-in default. The credential is either a token or an API client's
clientIdandclientSecret:tokenreadsMEMCO_API_TOKEN— falling back to the deprecatedMEMCO_API_KEY, which warns — and the pair readsMEMCO_CLIENT_IDandMEMCO_CLIENT_SECRET, which win overMEMCO_API_TOKENwhen both are set and no credential is passed.hostreadsMEMCO_API_HOST,tlsreadsMEMCO_API_TLS— TLS stays on unless one of them turns it off — andlogLevelreadsMEMCO_LOG. The rest have no variable:timeoutdefaults to DEFAULT_TIMEOUT seconds, the deadline every call inherits, andtokenLifetimeto the service's own. 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, half a client pair 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.