flags

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 20 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) ExperimentFlag added in v0.2.0

func (s *Store) ExperimentFlag(ctx context.Context, project workspace.ProjectID, key string) (experiments.FlagFacts, error)

ExperimentFlag returns the facts about project's flag with key that an experiment is judged against, or appexperiments.ErrNotFound.

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) FlagExperiments added in v0.2.0

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

FlagExperiments returns the experiments of flag, whatever their status, by key in byte order.

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) HoldingConfigurations added in v0.4.0

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

HoldingConfigurations returns the configurations of project, one per flag and environment, that have a rule serving the experiment keyed key, as references ordered by flag key, then by the environments' order.

func (*Store) HoldingEnvironments added in v0.2.0

func (s *Store) HoldingEnvironments(ctx context.Context, project workspace.ProjectID, key string) ([]workspace.EnvironmentID, error)

HoldingEnvironments returns the environments of project whose configuration of some flag has a rule serving the experiment keyed key, each once.

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) ProjectConfigurations added in v0.3.0

func (s *Store) ProjectConfigurations(ctx context.Context, project workspace.ProjectID) (map[flags.FlagID][]flags.EnvironmentConfiguration, error)

ProjectConfigurations returns the configuration of every flag of project in every environment, by flag, each flag's by the environments' order, all in one query.

func (*Store) ProjectExperiments added in v0.2.0

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

ProjectExperiments returns every experiment of project, whatever its status, by key in byte order.

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) RolloutSalts added in v0.2.0

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

RolloutSalts returns the salt of every rollout in every flag configuration of project, archived flags included: an archived flag can be restored, and its rollouts with it.

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) SegmentReferrers added in v0.2.0

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

SegmentReferrers returns the flags of project whose rules have a condition naming the segment key in some environment, archived flags included, by identifier, each once.

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) UnarchivedFlags added in v0.2.0

func (s *Store) UnarchivedFlags(ctx context.Context, project workspace.ProjectID, after string, limit int) ([]appflags.FlagView, error)

UnarchivedFlags returns up to limit of project's flags that are not archived, each with its configuration in every environment by the environments' order, by key in byte order, those whose key is greater than after when it is not "": two queries whatever the limit.

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