Documentation
¶
Overview ¶
Package experiments is the PostgreSQL repository of the experiments context.
Index ¶
- type Store
- func (s *Store) ActiveAlert(ctx context.Context, experiment experiments.ExperimentID, ...) (*experiments.Alert, error)
- func (s *Store) ActiveAlerts(ctx context.Context, experiment experiments.ExperimentID, ...) ([]experiments.Alert, error)
- func (s *Store) AlertOf(ctx context.Context, experiment experiments.ExperimentID, ...) (appexperiments.AlertView, error)
- func (s *Store) Alerts(ctx context.Context, experiment experiments.ExperimentID, active *bool) ([]appexperiments.AlertView, error)
- func (s *Store) CheckSalts(ctx context.Context) error
- func (s *Store) CreateExperiment(ctx context.Context, e experiments.Experiment) error
- func (s *Store) DeferSaltChecks(ctx context.Context) error
- func (s *Store) DeleteExperiment(ctx context.Context, experiment experiments.ExperimentID) error
- func (s *Store) EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string) (workspace.EnvironmentID, error)
- func (s *Store) ExperimentByKey(ctx context.Context, project workspace.ProjectID, key string) (experiments.Experiment, error)
- func (s *Store) ExperimentSalts(ctx context.Context, project workspace.ProjectID) ([]string, error)
- func (s *Store) Experiments(ctx context.Context, project workspace.ProjectID, ...) ([]experiments.Experiment, error)
- func (s *Store) LockProject(ctx context.Context, project workspace.ProjectID) error
- func (s *Store) PendingFinalEnvironments(ctx context.Context, experiment experiments.ExperimentID) ([]workspace.EnvironmentID, error)
- func (s *Store) PendingFinalExperiments(ctx context.Context) ([]experiments.Experiment, error)
- func (s *Store) ProjectExperiments(ctx context.Context, project workspace.ProjectID) ([]experiments.Experiment, error)
- func (s *Store) RunningExperiments(ctx context.Context) ([]experiments.Experiment, error)
- func (s *Store) RunningExperimentsOf(ctx context.Context, project workspace.ProjectID) ([]experiments.Experiment, error)
- func (s *Store) SampleRatioOf(ctx context.Context, experiment experiments.ExperimentID, ...) (*appexperiments.SampleRatioState, error)
- func (s *Store) SaveAlert(ctx context.Context, a experiments.Alert) error
- func (s *Store) SaveSampleRatio(ctx context.Context, experiment experiments.ExperimentID, ...) error
- func (s *Store) TryLockChecks(ctx context.Context) (release func(), held bool, err error)
- func (s *Store) UpdateExperiment(ctx context.Context, e experiments.Experiment) error
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 (*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 ¶
func (s *Store) AlertOf(ctx context.Context, experiment experiments.ExperimentID, alert experiments.AlertID) (appexperiments.AlertView, error)
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) CheckSalts ¶ added in v0.3.0
CheckSalts checks now that no two experiments of a project share a salt, and from then on at every write, so that a unit of work rolled back is checked as one committed would be.
func (*Store) CreateExperiment ¶
func (s *Store) CreateExperiment(ctx context.Context, e experiments.Experiment) error
CreateExperiment stores e. Only an import creates an experiment past its draft, with the decision a stop recorded.
func (*Store) DeferSaltChecks ¶ added in v0.3.0
DeferSaltChecks makes the database check that no two experiments of a project share a salt only when the unit of work ends, or when CheckSalts asks: until then one experiment may take a salt another is about to give up.
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 ¶
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 ¶
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) PendingFinalEnvironments ¶ added in v0.3.0
func (s *Store) PendingFinalEnvironments(ctx context.Context, experiment experiments.ExperimentID) ([]workspace.EnvironmentID, error)
PendingFinalEnvironments returns the environments in which experiment's sample-ratio result is not final.
func (*Store) PendingFinalExperiments ¶ added in v0.3.0
func (s *Store) PendingFinalExperiments(ctx context.Context) ([]experiments.Experiment, error)
PendingFinalExperiments returns the stopped or archived experiments of every project with a sample-ratio result that is not final.
func (*Store) ProjectExperiments ¶ added in v0.3.0
func (s *Store) ProjectExperiments(ctx context.Context, project workspace.ProjectID) ([]experiments.Experiment, error)
ProjectExperiments returns every experiment of project, whatever its status, by key in byte order.
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 ¶
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, final bool, ) error
SaveSampleRatio stores r, checked at, as the latest check of experiment in environment, final when nothing is left to wait for.
func (*Store) TryLockChecks ¶
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.