Documentation
¶
Overview ¶
Package feature resolves plan defaults and tenant-level feature overrides.
Index ¶
- Variables
- type Flag
- type MemoryStore
- func (store *MemoryStore) List(ctx context.Context, tenantID types.TenantID, planID string) ([]Flag, error)
- func (store *MemoryStore) Resolve(ctx context.Context, tenantID types.TenantID, planID string, key string) (Flag, error)
- func (store *MemoryStore) SetPlanDefaults(ctx context.Context, planID string, flags []Flag) error
- func (store *MemoryStore) SetTenantOverrides(ctx context.Context, tenantID types.TenantID, flags []Flag) error
- type Store
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 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 ¶
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.
Click to show internal directories.
Click to hide internal directories.