feature

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidFeature reports invalid feature input.
	ErrInvalidFeature = errors.New("gotenancy/feature: invalid feature")

	// ErrFeatureNotFound reports a missing feature flag.
	ErrFeatureNotFound = errors.New("gotenancy/feature: feature not found")
)

Functions

This section is empty.

Types

type Flag

type Flag struct {
	Key     string
	Enabled bool
	Config  map[string]string
}

Flag describes a feature flag.

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

MemoryStore stores feature flags in memory.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates an empty feature store.

func (*MemoryStore) List

func (store *MemoryStore) List(ctx context.Context, tenantID types.TenantID, planID string) ([]Flag, error)

List returns merged feature flags.

func (*MemoryStore) Resolve

func (store *MemoryStore) Resolve(ctx context.Context, tenantID types.TenantID, planID string, key string) (Flag, error)

Resolve returns the tenant override when present, otherwise the plan default.

func (*MemoryStore) SetPlanDefaults

func (store *MemoryStore) SetPlanDefaults(ctx context.Context, planID string, flags []Flag) error

SetPlanDefaults replaces default flags for a plan.

func (*MemoryStore) SetTenantOverrides

func (store *MemoryStore) SetTenantOverrides(ctx context.Context, tenantID types.TenantID, flags []Flag) error

SetTenantOverrides replaces tenant-level overrides.

type Store

type Store interface {
	SetPlanDefaults(ctx context.Context, planID string, flags []Flag) error
	SetTenantOverrides(ctx context.Context, tenantID types.TenantID, flags []Flag) error
	Resolve(ctx context.Context, tenantID types.TenantID, planID string, key string) (Flag, error)
	List(ctx context.Context, tenantID types.TenantID, planID string) ([]Flag, error)
}

Store persists plan defaults and tenant overrides.

Jump to

Keyboard shortcuts

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