experiments

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package experiments is the PostgreSQL repository of the experiments context.

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 experiments.

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore returns the repository on pool.

func (*Store) ActiveAlert

func (s *Store) ActiveAlert(ctx context.Context, experiment experiments.ExperimentID, environment *workspace.EnvironmentID,
	kind experiments.AlertKind,
) (*experiments.Alert, error)

ActiveAlert returns the active alert of kind of experiment in environment, nil for the experiment as a whole, locked until the unit of work ends; nil when there is none.

func (*Store) ActiveAlerts

func (s *Store) ActiveAlerts(ctx context.Context, experiment experiments.ExperimentID, kind experiments.AlertKind,
) ([]experiments.Alert, error)

ActiveAlerts returns the active alerts of kind of experiment, in every environment, locked until the unit of work ends.

func (*Store) AlertOf

AlertOf returns experiment's alert alert, locked until the unit of work ends, or appexperiments.ErrNotFound.

func (*Store) Alerts

func (s *Store) Alerts(ctx context.Context, experiment experiments.ExperimentID, active *bool) ([]appexperiments.AlertView, error)

Alerts returns experiment's alerts, the most recently raised first; active, when not nil, keeps only the active (true) or the cleared (false) ones.

func (*Store) CreateExperiment

func (s *Store) CreateExperiment(ctx context.Context, e experiments.Experiment) error

CreateExperiment stores e.

func (*Store) DeleteExperiment

func (s *Store) DeleteExperiment(ctx context.Context, experiment experiments.ExperimentID) error

DeleteExperiment deletes the experiment.

func (*Store) EnvironmentByKey

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

EnvironmentByKey returns project's environment keyed key, or appexperiments.ErrNotFound.

func (*Store) ExperimentByKey

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

ExperimentByKey returns project's experiment with key, or appexperiments.ErrNotFound.

func (*Store) ExperimentSalts

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

ExperimentSalts returns both salts of every experiment of project.

func (*Store) Experiments

func (s *Store) Experiments(ctx context.Context, project workspace.ProjectID, filter appexperiments.ExperimentFilter,
	now time.Time, after string, limit int) ([]experiments.Experiment, error)

Experiments returns up to limit experiments of project matching filter by key in byte order, those whose key is greater than after when it is not "".

An experiment is awaiting code removal in an environment where its flag's latest SDK evaluation came after the stop and an SDK reported evaluating it on a recent day: the latest evaluation says the flag outlived the decision, the day says it still does.

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 appexperiments.ErrNotFound when there is none. It is the lock the flags context's writes take, so the two contexts' writes of a project run one at a time.

func (*Store) RunningExperiments

func (s *Store) RunningExperiments(ctx context.Context) ([]experiments.Experiment, error)

RunningExperiments returns the running experiments of every project.

func (*Store) RunningExperimentsOf

func (s *Store) RunningExperimentsOf(ctx context.Context, project workspace.ProjectID) ([]experiments.Experiment, error)

RunningExperimentsOf returns project's running experiments.

func (*Store) SampleRatioOf

func (s *Store) SampleRatioOf(ctx context.Context, experiment experiments.ExperimentID, environment workspace.EnvironmentID,
) (*appexperiments.SampleRatioState, error)

SampleRatioOf returns the latest sample-ratio check of experiment in environment, nil before the first.

func (*Store) SaveAlert

func (s *Store) SaveAlert(ctx context.Context, a experiments.Alert) error

SaveAlert stores a, new or changed. Only when it clears and when it is acknowledged does an alert change.

func (*Store) SaveSampleRatio

func (s *Store) SaveSampleRatio(ctx context.Context, experiment experiments.ExperimentID, environment workspace.EnvironmentID,
	r experiments.SampleRatio, at time.Time,
) error

SaveSampleRatio stores r, checked at, as the latest check of experiment in environment.

func (*Store) TryLockChecks

func (s *Store) TryLockChecks(ctx context.Context) (release func(), held bool, err error)

TryLockChecks takes the checks' lock on a connection of its own, held across the round's units of work without keeping a transaction open, which would hold the rollups' snapshot horizon back for the whole round.

func (*Store) UpdateExperiment

func (s *Store) UpdateExperiment(ctx context.Context, e experiments.Experiment) error

UpdateExperiment stores the changed definition e, which keeps its key, project and creation.

Jump to

Keyboard shortcuts

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