Features

Configuration

Config reference, YAML example, and options for Feature Flags

YAML Configuration Example

config.yaml
extensions:
  features:
    enabled: true
    provider: "local"                # "local", "launchdarkly", "unleash", "flagsmith", "posthog"
    refreshInterval: "30s"
    enableCache: true
    cacheTTL: "5m"

    defaultFlags:
      new-dashboard: true
      max-items: 100

    local:
      flags:
        new-dashboard:
          enabled: true
          defaultValue: true
        dark-mode:
          enabled: false
          defaultValue: false
        max-items:
          enabled: true
          defaultValue: 50

The extension loads config from extensions.features first, falling back to features.

Programmatic Configuration

ext := features.NewExtension(
    features.WithProvider("local"),
    features.WithRefreshInterval(1 * time.Minute),
    features.WithCache(true, 10*time.Minute),
    features.WithDefaultFlags(map[string]any{
        "new-dashboard": true,
        "max-items":     100,
    }),
)

Config Struct Reference

FieldTypeDefaultDescription
EnabledbooltrueEnable the extension
Providerstring"local"Feature flag provider
RefreshIntervaltime.Duration30sFlag refresh interval
EnableCachebooltrueEnable flag value caching
CacheTTLtime.Duration5mCache TTL
DefaultFlagsmap[string]any{}Default flag values
Local.Flagsmap[string]FlagConfig{}Local flag definitions

FlagConfig

FieldTypeDescription
EnabledboolWhether the flag is active
DefaultValueanyDefault value when enabled

Option Helpers

FunctionDescription
WithProvider(provider)Set the flag provider
WithRefreshInterval(interval)Set refresh interval
WithCache(enabled, ttl)Configure caching
WithDefaultFlags(flags)Set default flag values
WithConfig(config)Provide a complete config struct

How is this guide?

On this page