flags

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package flags is the PostgreSQL repository of the flags context: flags, their configuration in each environment, and segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is the repository of flags, configurations and segments.

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore returns the repository on pool.

func (*Store) Configuration

func (s *Store) Configuration(ctx context.Context, flag flags.FlagID, environment string) (flags.EnvironmentConfiguration, error)

Configuration returns flag's configuration in the environment keyed environment, or appflags.ErrNotFound when its project has no such environment.

func (*Store) Configurations

func (s *Store) Configurations(ctx context.Context, flag flags.FlagID) ([]flags.EnvironmentConfiguration, error)

Configurations returns flag's configuration in every environment, by the environments' order.

func (*Store) CreateConfigurations

func (s *Store) CreateConfigurations(ctx context.Context, cs []flags.Configuration) error

CreateConfigurations stores cs.

func (*Store) CreateFlag

func (s *Store) CreateFlag(ctx context.Context, f flags.Flag) error

CreateFlag stores f.

func (*Store) CreateSegment

func (s *Store) CreateSegment(ctx context.Context, seg flags.Segment) error

CreateSegment stores s.

func (*Store) DeclarationReferences

func (s *Store) DeclarationReferences(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)

DeclarationReferences returns what in project names the unit type or attribute keyed key: the segments whose conditions name it, by key, then one reference per flag and environment whose configuration names it in a rule's condition, a rollout or an override, archived flags included, by flag key and then environment order. A unit type and an attribute never share a key, so the key alone says which is meant, and a unit type is named as an attribute too, holding the unit's ID. Containment of the key finds every kind through the GIN indexes on segments' conditions and configurations' documents.

func (*Store) DeclarationUsageCounts

func (s *Store) DeclarationUsageCounts(ctx context.Context, project workspace.ProjectID) (map[string]int, error)

DeclarationUsageCounts returns, by the key of each unit type or attribute of project something names, how many flags and segments name it: a flag, archived ones included, once whatever its environments and however many rules, rollouts and overrides name it there, as DeclarationReferences finds them; a segment once however many of its conditions do. One query answers every declaration of the project.

func (*Store) DeleteFlag

func (s *Store) DeleteFlag(ctx context.Context, flag flags.FlagID) error

DeleteFlag deletes the flag with its configurations.

func (*Store) DeleteSegment

func (s *Store) DeleteSegment(ctx context.Context, segment flags.SegmentID) error

DeleteSegment deletes the segment.

func (*Store) Dependents

func (s *Store) Dependents(ctx context.Context, project workspace.ProjectID, flag string) ([]flags.Dependent, error)

Dependents returns every flag of project whose configuration in an environment requires a variation of the flag keyed flag, archived flags included, once per variation, by flag key, then environment order, then variation. Containment of the flag key finds both kinds of requirement through the configurations' GIN index.

func (*Store) EnvironmentConfigurations

func (s *Store) EnvironmentConfigurations(ctx context.Context, environment workspace.EnvironmentID) ([]flags.Configuration, error)

EnvironmentConfigurations returns the configuration of every flag of environment's project there, archived flags included.

func (*Store) FlagByKey

func (s *Store) FlagByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)

FlagByKey returns project's flag with key, or appflags.ErrNotFound.

func (*Store) Flags

func (s *Store) Flags(ctx context.Context, q appflags.FlagQuery, each func(appflags.QueriedFlag) bool) error

Flags calls each with the flags q lists, in q's order, each with its state in every environment and, when q compares two environments, its configurations in both, until each answers false or the flags run out, all in one query. A comparison reads only the flags whose two documents differ: equal documents carry the same ruleset, and what else differs is judged by the caller.

func (*Store) LockProject

func (s *Store) LockProject(ctx context.Context, project workspace.ProjectID) error

LockProject locks project's row for the unit of work, or answers appflags.ErrNotFound when there is none.

func (*Store) ProjectFlags

func (s *Store) ProjectFlags(ctx context.Context, project workspace.ProjectID) ([]flags.Flag, error)

ProjectFlags returns every flag of project, archived ones included.

func (*Store) Requirements

func (s *Store) Requirements(ctx context.Context, environment workspace.EnvironmentID) (flags.Requirements, error)

Requirements returns, by flag key, the keys of the flags each flag's configuration in environment requires, through its prerequisites and its rules' prerequisite conditions, archived flags included, each in byte order and once.

func (*Store) SegmentByKey

func (s *Store) SegmentByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)

SegmentByKey returns project's segment with key, or appflags.ErrNotFound.

func (*Store) SegmentUsageCounts

func (s *Store) SegmentUsageCounts(ctx context.Context, project workspace.ProjectID) (map[string]int, error)

SegmentUsageCounts returns, by the key of each segment of project a rule names, how many flags' rules name it, archived flags included, each flag once whatever its environments, as SegmentUsages finds them. One query answers every segment of the project.

func (*Store) SegmentUsages

func (s *Store) SegmentUsages(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)

SegmentUsages returns one reference per flag and environment of project whose rules have a condition naming the segment key, archived flags included, by flag key and then environment order. Only a segment condition names a segment, so containment of the key alone finds both kinds, through the configurations' GIN index.

func (*Store) Segments

func (s *Store) Segments(ctx context.Context, project workspace.ProjectID) ([]flags.Segment, error)

Segments returns project's segments by key.

func (*Store) UpdateConfiguration

func (s *Store) UpdateConfiguration(ctx context.Context, c flags.Configuration) error

UpdateConfiguration stores c's changes.

func (*Store) UpdateFlag

func (s *Store) UpdateFlag(ctx context.Context, f flags.Flag) error

UpdateFlag stores f's definition.

func (*Store) UpdateSegment

func (s *Store) UpdateSegment(ctx context.Context, seg flags.Segment) error

UpdateSegment stores s's changes.

Jump to

Keyboard shortcuts

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