featureflag

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

featureflag — wrapper around go-feature-flag

import "github.com/downsized-devs/sdk-go/featureflag"

Stability: Beta — no tests in package. See STABILITY.md.

Wraps go-feature-flag for user-targeted boolean and JSON flag evaluation.

Features

  • CheckUserFlags(ctx, user, defaults) — evaluate flags for a user.
  • GetAllUserFlags(ctx, user) — full flag snapshot.
  • Refresh() — pull updated rules from the configured retriever.

Installation

go get github.com/downsized-devs/sdk-go/featureflag

Quick Start

ff := featureflag.Init(featureflag.Config{
    Enabled: true,
    PollingInterval: 60,
    Retriever: featureflag.Retriever{ /* file/HTTP/S3 source */ },
}, log)
defer ff.Close()

flags := ff.CheckUserFlags(ctx, ffuser.NewUser("alice"), map[string]any{"newCheckout": false})

API Reference

Symbol Signature
Init func Init(cfg Config, log logger.Interface) Interface
Interface.CheckUserFlags (ctx, user, defaults) map[string]any
Interface.GetAllUserFlags (ctx, user) map[string]any
Interface.Refresh () error

Configuration

See Config in featureflag.go — fields cover enable toggle, polling interval, retriever source (file / HTTP / S3).

Dependencies

  • Internal: logger
  • External: github.com/thomaspoignant/go-feature-flag, .../ffuser, .../retriever

Testing

No tests yet. When adding them, mock the go-feature-flag client with gomock.

go test ./featureflag/...

Contributing

See CONTRIBUTING.md. Test coverage gates promotion to Stable.

  • logger — required at Init time.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool
	PollingInterval time.Duration
}

type Interface

type Interface interface {
	CheckUserFlags(flagKey, userKey, userType string, value map[string]interface{}) (bool, error)
	GetAllUserFlags(userKey, userType string, value map[string]interface{}) ([]byte, error)
	Refresh()
}

func Init

func Init(cfg Config, log logger.Interface, ret retriever.Retriever) Interface

Jump to

Keyboard shortcuts

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