bunadapter

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTable = "feature_flags"

DefaultTable is the default table name for feature flag overrides.

Variables

View Source
var ErrDBRequired = ferrors.ErrStoreRequired

ErrDBRequired indicates the underlying Bun DB is missing.

View Source
var ErrInvalidKey = ferrors.ErrInvalidKey

ErrInvalidKey indicates a missing or invalid feature key.

Functions

This section is empty.

Types

type FeatureFlagRecord

type FeatureFlagRecord struct {
	bun.BaseModel `bun:"table:feature_flags"`
	Key           string    `bun:"key,pk"`
	ScopeType     string    `bun:"scope_type,pk"`
	ScopeID       string    `bun:"scope_id,pk"`
	Enabled       *bool     `bun:"enabled,nullzero"`
	UpdatedBy     string    `bun:"updated_by,nullzero"`
	UpdatedAt     time.Time `bun:"updated_at,nullzero"`
}

FeatureFlagRecord maps to the feature_flags table.

type Option

type Option func(*Store)

Option customizes the Bun store adapter.

func WithNowFunc

func WithNowFunc(now func() time.Time) Option

WithNowFunc overrides the timestamp function used for updates.

func WithTable

func WithTable(table string) Option

WithTable sets the table name used for overrides.

func WithUpdatedByBuilder

func WithUpdatedByBuilder(builder func(gate.ActorRef) string) Option

WithUpdatedByBuilder overrides the updated_by value builder.

type Store

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

Store adapts Bun DB operations to featuregate overrides.

func NewStore

func NewStore(db bun.IDB, opts ...Option) *Store

NewStore constructs a new Bun-backed override store.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string, scopeRef gate.ScopeRef) error

Delete removes a stored override row.

func (*Store) GetAll added in v0.5.0

func (s *Store) GetAll(ctx context.Context, key string, chain gate.ScopeChain) ([]store.OverrideMatch, error)

GetAll implements store.Reader.

func (*Store) Set

func (s *Store) Set(ctx context.Context, key string, scopeRef gate.ScopeRef, enabled bool, actor gate.ActorRef) error

Set implements store.Writer.

func (*Store) Unset

func (s *Store) Unset(ctx context.Context, key string, scopeRef gate.ScopeRef, actor gate.ActorRef) error

Unset implements store.Writer.

Jump to

Keyboard shortcuts

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