Skip to main content
nexus.Config is a plain Go struct holding every value required to construct a client. Pass a value (not a pointer) to NewClient.
The context bounds construction - the WIF token exchange and the initial sync - and nothing after it, so passing one with a deadline is safe. Close is what ends a client. Values are validated here rather than coerced at the point of use, so a mistake is reported where it was written with the offending value named. TTL: 60 is rejected, for instance: a bare number is nanoseconds.

Field reference

API key types

Calling GetSecret(...) with a public key returns ErrPublicKeyRestricted synchronously, before the network call.

Where to keep the API key

For services, the conventional Go pattern is environment variables:
Pair with os.LookupEnv for explicit “missing” handling, or with libraries like github.com/caarlos0/env or github.com/kelseyhightower/envconfig. The SDK never logs the raw key. Log lines reference key type only:

Choosing the TTL

The TTL is a tradeoff between staleness window and redundant network traffic. With SSE enabled (started automatically by NewClient), changes propagate in milliseconds regardless of the TTL - the TTL only matters as a safety net if the stream falls back.
The SDK does not clamp or adjust the configured TTL based on stream state. With SSE connected, changes still arrive as events immediately; the TTL only governs the separate periodic background refresh, so setting it very low mostly adds redundant network requests rather than faster updates.

Custom HTTP client

For tests or when you want explicit control over timeouts / TLS:
If HTTPClient is nil, the SDK builds its own with a 10-second timeout.

Two clients under the hood

The SDK uses two distinct HTTP clients internally:
  1. The short-request client - your Config.HTTPClient verbatim (or the default 10 s-timeout client). Used for /v1/sync, /v1/auth/token-exchange, and any future short request. May carry any total request timeout you choose.
  2. A streaming client - derived from your client at construction time (a value-copy with Timeout cleared). Used exclusively for the long-lived /v1/stream SSE connection.
This split is not optional - Go’s http.Client.Timeout applies to the entire request including reading the response body, so a single shared client with a non-zero Timeout would kill SSE connections at the timeout boundary regardless of activity. The SDK makes the split for you so you can keep your familiar http.Client{Timeout: 10*time.Second} pattern without breaking the stream.
The streaming client inherits everything else from your client - Transport (proxies, custom TLS, instrumentation), Jar (cookies), CheckRedirect. Cancellation of the SSE goroutine is provided exclusively by the context.Context you pass to RunStream(ctx). If your client has a non-zero Timeout, the SDK emits a Debug-level log note at startup recording the split: