client

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(config config.Config) (core.Client, error)

NewClient creates a new feature flag client with the given configuration. This is the primary constructor for creating a feature flag client.

The client will be configured according to the provided Config, including:

  • Storage backend (memory, Redis, or PostgreSQL)
  • Caching settings (TTL, max size, enabled/disabled)
  • Observability settings (logging and metrics)
  • Default flags to load on startup

Example usage:

config := featureflag.Config{
	Storage: featureflag.StorageConfig{
		Type: "redis",
		Redis: &featureflag.RedisConfig{
			Addr: "localhost:6379",
		},
	},
	Cache: featureflag.CacheConfig{
		Enabled: true,
		TTL:     featureflag.Duration(5 * time.Minute),
		MaxSize: 1000,
	},
}

client, err := featureflag.NewClient(config)
if err != nil {
	log.Fatal(err)
}
defer client.Close()

Parameters:

  • config: Configuration for the client

Returns:

  • Client: The configured client instance
  • error: Configuration validation errors or initialization errors

func NewClientWithDefaults

func NewClientWithDefaults() (core.Client, error)

NewClientWithDefaults creates a new client with default configuration. This is a convenience constructor that uses sensible defaults:

  • In-memory storage (no external dependencies)
  • Caching enabled with 5-minute TTL and 1000 item limit
  • Logging disabled
  • Metrics disabled
  • No default flags

This is ideal for development, testing, or simple use cases where you don't need persistent storage or advanced configuration.

Example usage:

client, err := featureflag.NewClientWithDefaults()
if err != nil {
	log.Fatal(err)
}
defer client.Close()

// Client is ready to use
enabled, _ := client.IsEnabled(ctx, "my-feature")

Returns:

  • Client: The client with default configuration
  • error: Initialization errors (rare with default config)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL