Overview
flagmint.NewClient accepts a variadic list of Option values produced by
the With* helper functions. Options are applied in order; later options
override earlier ones.
Options Reference
WithContext(ctx EvaluationContext)
Sets the evaluation context on initial connection. This context is used to determine which flag variations the user receives based on targeting rules.
WithContext(...)inNewClient()— Set the context before the first flag fetchclient.UpdateContext(ctx)— Change the context at runtime (e.g., when user attributes change)
WithTransportMode(mode TransportMode)
Controls how the SDK communicates with the Flagmint backend.
| Constant | Value | Description |
|---|---|---|
TransportAuto | "auto" | WebSocket preferred, falls back to HTTP (default) |
TransportWebSocket | "websocket" | Force WebSocket |
TransportLongPolling | "long-polling" | Force HTTP long-polling |
WithLocalEvaluation()
Enables local flag evaluation. Flags are evaluated in-process using downloaded
rule configurations instead of being evaluated server-side.
WithCache(enabled bool)
Enables (or disables) the built-in in-memory flag cache. When enabled, the
SDK serves cached flags immediately on startup while the transport reconnects
(degraded-mode support).
WithCacheAdapter(adapter CacheAdapter)
Replaces the built-in cache with a custom implementation. Automatically
enables caching.
CacheAdapter interface and examples.
WithOnError(fn func(error))
Registers a callback invoked for non-fatal errors such as failed flag
refreshes or cache write failures.
WithEndpoints(rest, ws string)
Overrides the default production API endpoints. Useful for staging, local
development, or private deployments.
| Variable | Description |
|---|---|
FLAGMINT_REST_ENDPOINT | Override the REST/HTTP endpoint |
FLAGMINT_WS_ENDPOINT | Override the WebSocket endpoint |
FLAGMINT_ENV | Short alias: local, staging, or prod |
WithDeferInit()
Prevents the client from connecting immediately. Call client.Initialize(ctx)
or client.Ready(ctx) when ready to connect.
WithLogger(l *slog.Logger)
Supplies a custom structured logger (Go standard library log/slog). By
default, the SDK uses slog.Default().
Evaluation Context Structure
TheEvaluationContext tells Flagmint who is requesting flag evaluations and
is used for targeting rules and percentage rollouts.
Flag Value Types
The SDK provides typed getter methods that return a fallback when the flag is missing or has a different type:Thread Safety
FlagClient is safe for concurrent use by multiple goroutines. All public
methods (BoolFlag, StringFlag, GetFlags, UpdateContext, Subscribe,
Close, etc.) may be called from any goroutine without additional
synchronisation.
Note: This SDK is pre-stable (v0.1.0). Breaking changes may occur beforev1.0.0.