Documentation
¶
Overview ¶
Package flags holds the use cases of the flags context: flags, their configuration in each environment, and segments. Every write locks its project's row first and nothing else, so the writes of one project run one at a time and every rule spanning several flags and segments, checked over what the handler loaded, holds when the write commits.
Index ¶
- Variables
- type AllConfigurations
- type ApplyExperimentDecision
- type ApplyExperimentDecisionDeps
- type ApplyProposal
- type ArchivalDeps
- type ArchiveFlag
- type ArchiveFlagDeps
- type AuditLog
- type ConfigurationCommand
- type ConfigurationCreator
- type ConfigurationDeps
- type ConfigurationDrafter
- type ConfigurationHistory
- type ConfigurationReader
- type ConfigurationReplacer
- type ConfigurationWriter
- type ConfigureEnvironment
- type CopyConfiguration
- type CopyConfigurationCommand
- type CreateFlag
- type CreateFlagCommand
- type CreateFlagDeps
- type CreateSegment
- type CreateSegmentCommand
- type CreateSegmentDeps
- type DeclarationGuard
- type DeclarationReferenceFinder
- type DeclarationUsageCounter
- type DeclarationUsages
- type Declarations
- type DefinitionUpdater
- type Definitions
- func (d *Definitions) ApplyFlag(ctx context.Context, project workspace.ProjectID, key string, ...) error
- func (d *Definitions) ApplySegment(ctx context.Context, project workspace.ProjectID, key string, ...) error
- func (d *Definitions) CurrentFlag(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
- func (d *Definitions) CurrentSegment(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
- func (d *Definitions) ProposeFlag(ctx context.Context, project workspace.ProjectID, key string, ...) (flags.Flag, flags.Flag, error)
- func (d *Definitions) ProposeSegment(ctx context.Context, project workspace.ProjectID, key string, ...) (flags.Segment, flags.Segment, error)
- func (d *Definitions) SegmentReferrers(ctx context.Context, project workspace.ProjectID, key string) ([]flags.FlagID, error)
- type DeleteFlag
- type DeleteFlagDeps
- type DeleteSegment
- type DeleteSegmentDeps
- type DependentFinder
- type DraftConfiguration
- func (h *DraftConfiguration) Current(ctx context.Context, project workspace.ProjectID, flag, environment string) (flags.Flag, flags.EnvironmentConfiguration, error)
- func (h *DraftConfiguration) Draft(ctx context.Context, project workspace.ProjectID, flag, environment string, ...) (flags.Configuration, error)
- func (h *DraftConfiguration) Propose(ctx context.Context, project workspace.ProjectID, flag, environment string, ...) (flags.Flag, flags.EnvironmentConfiguration, flags.Configuration, error)
- type Environments
- type ExperimentFinder
- type ExperimentHolders
- type ExperimentRuleStore
- type FlagArchiver
- type FlagCommand
- type FlagCreator
- type FlagCursor
- type FlagDeleter
- type FlagLister
- type FlagPage
- type FlagQuery
- type FlagReader
- type FlagSort
- type FlagState
- type FlagUpdater
- type FlagView
- type GetFlag
- type GetFlagConfiguration
- type GetSegment
- type KillFlag
- type KillFlagCommand
- type LastEvaluations
- type ListFlags
- type ListSegmentUsages
- type ListSegments
- type ListStaleFlags
- type ListedFlag
- type ListedSegment
- type Owners
- type ProjectLocker
- type QueriedFlag
- type Recorder
- type ReferentReader
- type ReferrerReader
- type RegenerateSalt
- type RegenerateSaltCommand
- type RemoveOverride
- type RemoveOverrideCommand
- type ReplaceConfiguration
- type ReplaceConfigurationCommand
- type ReplaceConfigurationDeps
- type RestoreFlag
- type RevertConfiguration
- func (h *RevertConfiguration) ApplyRevert(ctx context.Context, project workspace.ProjectID, flag, environment string, ...) error
- func (h *RevertConfiguration) Handle(ctx context.Context, cmd RevertConfigurationCommand) (flags.EnvironmentConfiguration, error)
- func (h *RevertConfiguration) ProposeRevert(ctx context.Context, project workspace.ProjectID, flag, environment string, ...) (flags.Flag, flags.EnvironmentConfiguration, flags.Configuration, error)
- type RevertConfigurationCommand
- type RevertConfigurationDeps
- type Rulesets
- type RunningExperiments
- type SegmentCommand
- type SegmentCreator
- type SegmentDeleter
- type SegmentLister
- type SegmentReader
- type SegmentReferrers
- type SegmentUpdater
- type SetOverride
- type SetOverrideCommand
- type SetOverrideDeps
- type Snapshotter
- type StaleDeps
- type StaleFlag
- type StaleFlagPage
- type StateFilter
- type SummaryDays
- type Transactor
- type UnarchivedFlagReader
- type UpdateFlag
- func (h *UpdateFlag) Apply(ctx context.Context, project workspace.ProjectID, key string, ...) error
- func (h *UpdateFlag) Current(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
- func (h *UpdateFlag) Handle(ctx context.Context, cmd UpdateFlagCommand) (FlagView, error)
- func (h *UpdateFlag) Propose(ctx context.Context, project workspace.ProjectID, key string, ...) (flags.Flag, flags.Flag, error)
- type UpdateFlagCommand
- type UpdateFlagDeps
- type UpdateSegment
- func (h *UpdateSegment) Apply(ctx context.Context, project workspace.ProjectID, key string, ...) error
- func (h *UpdateSegment) Current(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
- func (h *UpdateSegment) Handle(ctx context.Context, cmd UpdateSegmentCommand) (flags.Segment, error)
- func (h *UpdateSegment) Propose(ctx context.Context, project workspace.ProjectID, key string, ...) (flags.Segment, flags.Segment, error)
- type UpdateSegmentCommand
- type UpdateSegmentDeps
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("flags: not found")
ErrNotFound is what a store answers for an entity it does not hold.
Functions ¶
This section is empty.
Types ¶
type AllConfigurations ¶ added in v0.2.0
type AllConfigurations interface {
// Configurations returns the flag's configuration in every environment,
// by the environments' order.
Configurations(ctx context.Context, flag flags.FlagID) ([]flags.EnvironmentConfiguration, error)
}
AllConfigurations reads a flag's configurations.
type ApplyExperimentDecision ¶ added in v0.2.0
type ApplyExperimentDecision struct {
// contains filtered or unexported fields
}
ApplyExperimentDecision rewrites the rules serving an experiment as its stop decided.
func NewApplyExperimentDecision ¶ added in v0.2.0
func NewApplyExperimentDecision(d ApplyExperimentDecisionDeps) *ApplyExperimentDecision
NewApplyExperimentDecision returns the handler.
func (*ApplyExperimentDecision) ApplyDecision ¶ added in v0.2.0
func (h *ApplyExperimentDecision) ApplyDecision(ctx context.Context, project workspace.ProjectID, flag, experiment, winner string, by *access.MemberID, now time.Time, req governance.Request, ) error
ApplyDecision makes every rule of project's flag keyed flag serving the experiment keyed experiment serve the variation winner, or deletes it when winner is "", in every environment, as the member by (nil for a project token) at now in req. An experiment's rules are all its flag's, since a rule serving another flag's experiment is refused.
Each configuration it changes is a configuration write of its own, at its next version, recorded as flag.configuration_updated with the experiment its stop decided, so a revert finds the version and later readers of the audit log see the write as any other; the environment's ruleset moves on with it. It runs in the unit of work ctx carries, under the project's lock its caller took, so the stop and every rewrite commit together.
type ApplyExperimentDecisionDeps ¶ added in v0.2.0
type ApplyExperimentDecisionDeps struct {
Store ExperimentRuleStore
Rulesets Rulesets
Recorder Recorder
}
ApplyExperimentDecisionDeps are what ApplyExperimentDecision runs on.
type ApplyProposal ¶ added in v0.2.0
type ApplyProposal struct {
// contains filtered or unexported fields
}
ApplyProposal writes a flag's configuration in one environment as an approved change request proposes it.
func NewApplyProposal ¶ added in v0.2.0
func NewApplyProposal(d ReplaceConfigurationDeps) *ApplyProposal
NewApplyProposal returns the handler.
func (*ApplyProposal) Apply ¶ added in v0.2.0
func (h *ApplyProposal) Apply(ctx context.Context, project workspace.ProjectID, flag, environment string, proposed flags.ConfigurationInput, baseVersion int64, by *access.MemberID, req governance.Request, ) error
Apply writes proposed in place of the configuration of project's flag keyed flag in the environment keyed environment, based on its version baseVersion, in the unit of work ctx carries, which joins the change request's application; by is the member applying, nil for a project token or the system. It is recorded as a replace of the whole configuration is. The proposal keeps the rule identifiers and salts it was given, and is checked again as a replace is, since what it names may be gone since it was approved; a refusal rolls the application back. Whether the write may change a protected environment is the bypass ctx carries, as for every write.
type ArchivalDeps ¶
type ArchivalDeps struct {
Tx Transactor
Projects ProjectLocker
Store FlagUpdater
Rulesets Rulesets
Recorder Recorder
Evaluations LastEvaluations
}
ArchivalDeps are what restoring a flag runs on, and archiving one besides finding the flags that require it.
type ArchiveFlag ¶
type ArchiveFlag struct {
// contains filtered or unexported fields
}
ArchiveFlag archives a flag: SDKs stop receiving it in every environment, and its definition and configurations are kept until it is restored or deleted.
func NewArchiveFlag ¶
func NewArchiveFlag(d ArchiveFlagDeps) *ArchiveFlag
NewArchiveFlag returns the handler.
func (*ArchiveFlag) Handle ¶
func (h *ArchiveFlag) Handle(ctx context.Context, cmd FlagCommand) (FlagView, error)
Handle archives the flag and returns it; an archived flag stays as it is and nothing is recorded. A flag another flag requires, in any environment and archived or not, is not archived: the requiring flag would then require a flag no SDK receives. Nor is one with a draft or running experiment, which would lose its flag.
type ArchiveFlagDeps ¶
type ArchiveFlagDeps struct {
Tx Transactor
Projects ProjectLocker
Store FlagArchiver
Rulesets Rulesets
Recorder Recorder
Evaluations LastEvaluations
}
ArchiveFlagDeps are what ArchiveFlag runs on.
type AuditLog ¶
type AuditLog interface {
Record(ctx context.Context, e governance.Entry) error
}
AuditLog records the audit entry of a change, in the unit of work of the change.
type ConfigurationCommand ¶
type ConfigurationCommand struct {
Project workspace.ProjectID
Flag string
Environment string
Expected precondition.Version
Caller *access.MemberID
Request governance.Request
}
ConfigurationCommand names a flag's configuration in one environment of a project, and the version of it a write is based on. Caller is the member writing, nil for a project token.
type ConfigurationCreator ¶
type ConfigurationCreator interface {
// ProjectFlags returns every flag of project, archived ones included.
ProjectFlags(ctx context.Context, project workspace.ProjectID) ([]flags.Flag, error)
CreateConfigurations(ctx context.Context, cs []flags.Configuration) error
}
ConfigurationCreator stores the configurations of a new environment.
type ConfigurationDeps ¶
type ConfigurationDeps struct {
Tx Transactor
Projects ProjectLocker
Store ConfigurationWriter
Rulesets Rulesets
Recorder Recorder
}
ConfigurationDeps are what a write of one configuration runs on.
type ConfigurationDrafter ¶
type ConfigurationDrafter interface {
ConfigurationReader
ReferentReader
}
ConfigurationDrafter reads a flag's configuration and what a configuration may name.
type ConfigurationHistory ¶
type ConfigurationHistory interface {
// RecordedVersion returns the values the newest entry of project
// recording entity in environment holds for it at version, before or
// after its change, and whether an entry does.
RecordedVersion(ctx context.Context, project workspace.ProjectID, entity governance.Entity,
environment workspace.EnvironmentID, version int64) ([]byte, bool, error)
}
ConfigurationHistory finds the configurations the audit log recorded.
type ConfigurationReader ¶
type ConfigurationReader interface {
FlagByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
// Configuration returns the flag's configuration in the environment
// keyed environment, or ErrNotFound when the project has no such
// environment.
Configuration(ctx context.Context, flag flags.FlagID, environment string) (flags.EnvironmentConfiguration, error)
}
ConfigurationReader reads a flag's configuration in one environment.
type ConfigurationReplacer ¶
type ConfigurationReplacer interface {
ConfigurationWriter
ReferentReader
}
ConfigurationReplacer stores a flag's configuration replaced whole, and reads what it may name.
type ConfigurationWriter ¶
type ConfigurationWriter interface {
ConfigurationReader
UpdateConfiguration(ctx context.Context, c flags.Configuration) error
}
ConfigurationWriter stores a flag's changed configuration in one environment.
type ConfigureEnvironment ¶
type ConfigureEnvironment struct {
// contains filtered or unexported fields
}
ConfigureEnvironment gives a new environment a configuration of every flag of its project, archived ones included, so every flag exists in every environment as a restored flag expects.
func NewConfigureEnvironment ¶
func NewConfigureEnvironment(store ConfigurationCreator) *ConfigureEnvironment
NewConfigureEnvironment returns the handler.
func (*ConfigureEnvironment) ConfigureEnvironment ¶
func (h *ConfigureEnvironment) ConfigureEnvironment(ctx context.Context, e workspace.Environment, by *access.MemberID) error
ConfigureEnvironment configures every flag of the environment's project in it, switched off, as written by by, the member creating the environment (nil for a project token), in the unit of work ctx carries: the environment is new, so its ruleset starts at its first version and nothing is bumped; the environment's own audit entry records the creation.
type CopyConfiguration ¶
type CopyConfiguration struct {
// contains filtered or unexported fields
}
CopyConfiguration makes a flag's configuration in one environment serve what it serves in another.
func NewCopyConfiguration ¶
func NewCopyConfiguration(d ReplaceConfigurationDeps) *CopyConfiguration
NewCopyConfiguration returns the handler.
func (*CopyConfiguration) Handle ¶
func (h *CopyConfiguration) Handle(ctx context.Context, cmd CopyConfigurationCommand) (flags.EnvironmentConfiguration, error)
Handle copies and returns the target configuration as it is after. The source is read under the project's lock, so the copy is of what it is when the copy commits; the result is validated against the target's environment, then the target's version the write was based on is judged.
type CopyConfigurationCommand ¶
type CopyConfigurationCommand struct {
Configuration ConfigurationCommand
From string
Overrides bool
}
CopyConfigurationCommand copies to the configuration Configuration names the flag's configuration in the environment keyed From, its overrides too when Overrides is set.
type CreateFlag ¶
type CreateFlag struct {
// contains filtered or unexported fields
}
CreateFlag creates a flag, switched off in every environment of its project.
func NewCreateFlag ¶
func NewCreateFlag(d CreateFlagDeps) *CreateFlag
NewCreateFlag returns the handler.
func (*CreateFlag) Handle ¶
func (h *CreateFlag) Handle(ctx context.Context, cmd CreateFlagCommand) (FlagView, error)
Handle creates the flag and its configuration in every environment, which changes every environment's ruleset: SDKs now receive a flag they did not.
type CreateFlagCommand ¶
type CreateFlagCommand struct {
Project workspace.ProjectID
Key string
Type flags.Type
Name, Description string
Owner *access.MemberID
Caller *access.MemberID
Tags []string
Lifetime flags.Lifetime
ExpectedRemovalAt *time.Time
AutomaticExposure bool
Variations *[]flags.VariationInput
Request governance.Request
}
CreateFlagCommand is the flag to create. Owner is the member the request names, nil when it names none; Caller is the member making the request, nil for a project token.
type CreateFlagDeps ¶
type CreateFlagDeps struct {
Tx Transactor
Projects ProjectLocker
Environments Environments
Store FlagCreator
Owners Owners
Rulesets Rulesets
Recorder Recorder
}
CreateFlagDeps are what CreateFlag runs on.
type CreateSegment ¶
type CreateSegment struct {
// contains filtered or unexported fields
}
CreateSegment creates a segment.
func NewCreateSegment ¶
func NewCreateSegment(d CreateSegmentDeps) *CreateSegment
NewCreateSegment returns the handler.
func (*CreateSegment) Handle ¶
func (h *CreateSegment) Handle(ctx context.Context, cmd CreateSegmentCommand) (flags.Segment, error)
Handle creates the segment, checked against the project's declarations under its row lock, so no declaration it names is deleted meanwhile. Every environment's ruleset carries the project's segments, so each moves on.
type CreateSegmentCommand ¶
type CreateSegmentCommand struct {
Project workspace.ProjectID
Key string
Name, Description string
Private bool
Conditions []flags.Condition
Request governance.Request
}
CreateSegmentCommand is the segment to create.
type CreateSegmentDeps ¶
type CreateSegmentDeps struct {
Tx Transactor
Projects ProjectLocker
Declarations Declarations
Store SegmentCreator
Rulesets Rulesets
Recorder Recorder
}
CreateSegmentDeps are what CreateSegment runs on.
type DeclarationGuard ¶
type DeclarationGuard struct {
// contains filtered or unexported fields
}
DeclarationGuard keeps every rule, rollout, override and segment naming a declared unit type or attribute: the workspace context asks it before deleting one.
func NewDeclarationGuard ¶
func NewDeclarationGuard(store DeclarationReferenceFinder) *DeclarationGuard
NewDeclarationGuard returns the handler.
func (*DeclarationGuard) RefuseReferenced ¶
func (g *DeclarationGuard) RefuseReferenced(ctx context.Context, project workspace.ProjectID, key string) error
RefuseReferenced answers in_use, listing what names it, when a segment or a flag's configuration of project names the unit type or attribute keyed key, archived flags included, since a restored flag would come back naming something undeclared; nil when nothing does. The caller holds the project's lock, which every write naming a declaration takes too, so the answer holds until its unit of work ends.
type DeclarationReferenceFinder ¶
type DeclarationReferenceFinder interface {
// DeclarationReferences returns the segments whose conditions name the
// declaration key, then one reference per flag and environment whose
// rules, rollouts or overrides name it, archived flags included.
DeclarationReferences(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)
}
DeclarationReferenceFinder finds what names a unit type or attribute.
type DeclarationUsageCounter ¶
type DeclarationUsageCounter interface {
// DeclarationUsageCounts returns, by declaration key, how many flags
// and segments of project name it; a key nothing names is absent.
DeclarationUsageCounts(ctx context.Context, project workspace.ProjectID) (map[string]int, error)
}
DeclarationUsageCounter counts what names each unit type and attribute.
type DeclarationUsages ¶
type DeclarationUsages struct {
// contains filtered or unexported fields
}
DeclarationUsages tells the workspace context how many flags and segments name each of a project's unit types and attributes, for its lists.
func NewDeclarationUsages ¶
func NewDeclarationUsages(store DeclarationUsageCounter) *DeclarationUsages
NewDeclarationUsages returns the handler.
func (*DeclarationUsages) DeclarationUsageCounts ¶
func (h *DeclarationUsages) DeclarationUsageCounts(ctx context.Context, project workspace.ProjectID) (map[string]int, error)
DeclarationUsageCounts returns, by declaration key, how many flags, archived ones included, and segments of project name it, each counted once; a key nothing names is absent. It reads in the unit of work or snapshot ctx carries.
type Declarations ¶
type Declarations interface {
// UnitTypes returns the project's unit types.
UnitTypes(ctx context.Context, project workspace.ProjectID) ([]workspace.UnitType, error)
// Attributes returns the project's attributes.
Attributes(ctx context.Context, project workspace.ProjectID) ([]workspace.Attribute, error)
}
Declarations reads what a project's conditions may name.
type DefinitionUpdater ¶
type DefinitionUpdater interface {
FlagUpdater
DependentFinder
ExperimentFinder
}
DefinitionUpdater stores a flag's changed definition once nothing names what the change removes.
type Definitions ¶ added in v0.2.0
type Definitions struct {
// contains filtered or unexported fields
}
Definitions is a flag's and a segment's definition as a change request proposes, bases itself on and applies it: checked, read and written as a direct edit of the flag or the segment is.
func NewDefinitions ¶ added in v0.2.0
func NewDefinitions(flag *UpdateFlag, segment *UpdateSegment, referrers *SegmentReferrers) *Definitions
NewDefinitions returns the definitions edited through flag and segment, with the flags naming a segment read through referrers.
func (*Definitions) ApplyFlag ¶ added in v0.2.0
func (d *Definitions) ApplyFlag(ctx context.Context, project workspace.ProjectID, key string, change flags.FlagChange, baseVersion int64, req governance.Request, ) error
ApplyFlag makes change to project's flag keyed key, based on its version baseVersion, in the unit of work ctx carries.
func (*Definitions) ApplySegment ¶ added in v0.2.0
func (d *Definitions) ApplySegment(ctx context.Context, project workspace.ProjectID, key string, change flags.SegmentChange, baseVersion int64, req governance.Request, ) error
ApplySegment makes change to project's segment keyed key, based on its version baseVersion, in the unit of work ctx carries.
func (*Definitions) CurrentFlag ¶ added in v0.2.0
func (d *Definitions) CurrentFlag(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
CurrentFlag returns project's flag keyed key, or not_found.
func (*Definitions) CurrentSegment ¶ added in v0.2.0
func (d *Definitions) CurrentSegment(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
CurrentSegment returns project's segment keyed key, or not_found.
func (*Definitions) ProposeFlag ¶ added in v0.2.0
func (d *Definitions) ProposeFlag(ctx context.Context, project workspace.ProjectID, key string, change flags.FlagChange, ) (flags.Flag, flags.Flag, error)
ProposeFlag returns project's flag keyed key and the flag change would leave it as, with the refusals editing it would get.
func (*Definitions) ProposeSegment ¶ added in v0.2.0
func (d *Definitions) ProposeSegment(ctx context.Context, project workspace.ProjectID, key string, change flags.SegmentChange, ) (flags.Segment, flags.Segment, error)
ProposeSegment returns project's segment keyed key and the segment change would leave it as, with the refusals editing it would get.
func (*Definitions) SegmentReferrers ¶ added in v0.2.0
func (d *Definitions) SegmentReferrers(ctx context.Context, project workspace.ProjectID, key string) ([]flags.FlagID, error)
SegmentReferrers returns the flags of project whose rules name the segment key in some environment, archived flags included, each once.
type DeleteFlag ¶
type DeleteFlag struct {
// contains filtered or unexported fields
}
DeleteFlag deletes an archived flag.
func NewDeleteFlag ¶
func NewDeleteFlag(d DeleteFlagDeps) *DeleteFlag
NewDeleteFlag returns the handler.
func (*DeleteFlag) Handle ¶
func (h *DeleteFlag) Handle(ctx context.Context, cmd FlagCommand) error
Handle deletes the flag with its configuration in every environment, recording both as they were. An archived flag is in no ruleset already, so deleting it moves none on.
type DeleteFlagDeps ¶
type DeleteFlagDeps struct {
Tx Transactor
Projects ProjectLocker
Store FlagDeleter
Recorder Recorder
}
DeleteFlagDeps are what DeleteFlag runs on.
type DeleteSegment ¶
type DeleteSegment struct {
// contains filtered or unexported fields
}
DeleteSegment deletes a segment.
func NewDeleteSegment ¶
func NewDeleteSegment(d DeleteSegmentDeps) *DeleteSegment
NewDeleteSegment returns the handler.
func (*DeleteSegment) Handle ¶
func (h *DeleteSegment) Handle(ctx context.Context, cmd SegmentCommand) error
Handle deletes the segment, which leaves every environment's ruleset. A segment a rule names, an archived flag's included, is not deleted: the rule would name nothing, and a restored flag would come back broken.
type DeleteSegmentDeps ¶
type DeleteSegmentDeps struct {
Tx Transactor
Projects ProjectLocker
Store SegmentDeleter
Rulesets Rulesets
Recorder Recorder
}
DeleteSegmentDeps are what DeleteSegment runs on.
type DependentFinder ¶
type DependentFinder interface {
// Dependents returns every flag of project whose configuration in an
// environment requires a variation of the flag keyed flag, archived
// flags included, by flag key and then environment order.
Dependents(ctx context.Context, project workspace.ProjectID, flag string) ([]flags.Dependent, error)
}
DependentFinder finds the flags requiring a flag.
type DraftConfiguration ¶
type DraftConfiguration struct {
// contains filtered or unexported fields
}
DraftConfiguration checks an unsaved configuration of one flag as replacing the saved one would, for the delivery context to evaluate it, and stores and records nothing.
func NewDraftConfiguration ¶
func NewDraftConfiguration(declarations Declarations, store ConfigurationDrafter, ids *id.Source) *DraftConfiguration
NewDraftConfiguration returns the handler, giving a draft's new rules identifiers from ids.
func (*DraftConfiguration) Current ¶ added in v0.2.0
func (h *DraftConfiguration) Current(ctx context.Context, project workspace.ProjectID, flag, environment string, ) (flags.Flag, flags.EnvironmentConfiguration, error)
Current returns project's flag keyed flag and its saved configuration in the environment keyed environment, or not_found for either, as a proposal would be based on it now.
func (*DraftConfiguration) Draft ¶
func (h *DraftConfiguration) Draft(ctx context.Context, project workspace.ProjectID, flag, environment string, in flags.ConfigurationInput, ) (flags.Configuration, error)
Draft returns in as the configuration of project's flag keyed flag in the environment keyed environment it would replace the saved one with, or the refusal replacing it would get: not_found for either, archived for an archived flag, invalid_configuration with every field to fix. A new rule gets an identifier and a new rollout a salt, which no write ever sees. It reads in the unit of work or snapshot ctx carries, with no lock: nothing is written, so a write committed meanwhile only means the draft is checked against what was saved before it.
func (*DraftConfiguration) Propose ¶ added in v0.2.0
func (h *DraftConfiguration) Propose(ctx context.Context, project workspace.ProjectID, flag, environment string, in flags.ConfigurationInput, held []flags.RuleInput, ) (flags.Flag, flags.EnvironmentConfiguration, flags.Configuration, error)
Propose returns in, proposed to replace the configuration of project's flag keyed flag in the environment keyed environment, checked as Draft checks it once what only the saved configuration may hold is left out of it: a rule identifier it has no rule with, and a salt that is not its rule's. A proposal is kept while others write the configuration, so what it names that the saved one does not hold makes a new rule, not a refusal. New rules are given identifiers and new rollouts salts, which the proposal holds until it is applied: held are the rules of the proposal in revises, nil for a new one, whose identifiers and salts in keeps. It returns the flag, the saved configuration with its environment's key, and what replacing it with in would leave.
type Environments ¶
type Environments interface {
// Environments returns the project's environments by sort order.
Environments(ctx context.Context, project workspace.ProjectID) ([]workspace.Environment, error)
}
Environments lists a project's environments.
type ExperimentFinder ¶ added in v0.2.0
type ExperimentFinder interface {
// FlagExperiments returns the flag's experiments, whatever their
// status, by key in byte order.
FlagExperiments(ctx context.Context, flag flags.FlagID) ([]flags.ExperimentRef, error)
}
ExperimentFinder finds the experiments of a flag.
type ExperimentHolders ¶ added in v0.2.0
type ExperimentHolders struct {
// contains filtered or unexported fields
}
ExperimentHolders reads where an experiment's rules are: the rules belong to the flags context, which an experiment's change request is based on.
func NewExperimentHolders ¶ added in v0.2.0
func NewExperimentHolders(store AllConfigurations) *ExperimentHolders
NewExperimentHolders returns the reader of store.
func (*ExperimentHolders) HoldingConfigurations ¶ added in v0.2.0
func (h *ExperimentHolders) HoldingConfigurations(ctx context.Context, flag flags.FlagID, experiment string, ) ([]flags.EnvironmentConfiguration, error)
HoldingConfigurations returns the configurations of flag with a rule serving the experiment keyed experiment, by the environments' order, read in the unit of work ctx carries. An experiment's rules are all its flag's, since a rule serving another flag's experiment is refused.
type ExperimentRuleStore ¶ added in v0.2.0
type ExperimentRuleStore interface {
FlagByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
// Configurations returns flag's configuration in every environment.
Configurations(ctx context.Context, flag flags.FlagID) ([]flags.EnvironmentConfiguration, error)
UpdateConfiguration(ctx context.Context, c flags.Configuration) error
}
ExperimentRuleStore reads and rewrites the configurations of a flag.
type FlagArchiver ¶
type FlagArchiver interface {
FlagUpdater
DependentFinder
ExperimentFinder
}
FlagArchiver stores a flag archived once no other flag requires it.
type FlagCommand ¶
type FlagCommand struct {
Project workspace.ProjectID
Key string
Expected precondition.Version
Request governance.Request
}
FlagCommand names one flag of a project and the version of it a write is based on.
type FlagCreator ¶
type FlagCreator interface {
// CreateFlag refuses a key the project uses as already_exists.
CreateFlag(ctx context.Context, f flags.Flag) error
CreateConfigurations(ctx context.Context, cs []flags.Configuration) error
}
FlagCreator stores a new flag with its configurations.
type FlagCursor ¶
FlagCursor is where a page of flags starts: after the flag with these key, name and last change, in the page's order.
type FlagDeleter ¶
FlagDeleter deletes a flag with its configurations.
type FlagLister ¶
type FlagLister interface {
// Flags calls each with the flags q lists, in q's order, until each
// answers false or the flags run out, all in one query.
Flags(ctx context.Context, q FlagQuery, each func(QueriedFlag) bool) error
}
FlagLister lists a project's flags.
type FlagPage ¶
type FlagPage struct {
// Text is contained in the key or the name of every flag listed,
// ignoring case; "" for any.
Text string
// Type, Tag and Owner, when set, are every listed flag's.
Type flags.Type
Tag string
Owner *access.MemberID
// Archived lists the archived flags instead of the others.
Archived bool
// Environment is the key of the environment State is judged in; ""
// for none. State is "" for any.
Environment string
State StateFilter
// DiffersBetween are the keys of two environments every listed flag's
// configurations differ between in what their rulesets carry; nil for
// no comparison.
DiffersBetween *[2]string
Sort FlagSort
// After is where the page starts, nil for the first.
After *FlagCursor
Limit int
}
FlagPage asks for one page of a project's flags.
type FlagQuery ¶
type FlagQuery struct {
Project workspace.ProjectID
Text string
Type flags.Type
Tag string
Owner *access.MemberID
Archived bool
// In is the environment State is judged in, nil for no state filter.
In *workspace.EnvironmentID
State StateFilter
// Compared are the two environments whose configurations a comparison
// reads, nil for none.
Compared *[2]workspace.EnvironmentID
Sort FlagSort
After *FlagCursor
// Limit is how many flags the store answers at most, 0 for every one.
Limit int
}
FlagQuery is what the store lists: FlagPage with its environments found.
type FlagReader ¶
type FlagReader interface {
// FlagByKey returns project's flag with key, or ErrNotFound.
FlagByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
// Configurations returns the flag's configuration in every environment,
// by the environments' order.
Configurations(ctx context.Context, flag flags.FlagID) ([]flags.EnvironmentConfiguration, error)
}
FlagReader reads a flag with its configurations.
type FlagState ¶
type FlagState struct {
Environment string
On bool
HasRules bool
HasRollout bool
// HasExperiment is true when a rule serves an experiment.
HasExperiment bool
// LastEvaluatedAt is when an SDK last evaluated the flag in the
// environment, nil when none ever did.
LastEvaluatedAt *time.Time
}
FlagState is what a flag's configuration in one environment serves at a glance.
type FlagUpdater ¶
FlagUpdater stores a flag's changed definition.
type FlagView ¶
type FlagView struct {
Flag flags.Flag
Configurations []flags.EnvironmentConfiguration
// LastEvaluated is when an SDK last evaluated the flag, by environment
// key; an environment it was never evaluated in is absent.
LastEvaluated map[string]time.Time
}
FlagView is a flag with its configuration in every environment, by the environments' order.
type GetFlag ¶
type GetFlag struct {
// contains filtered or unexported fields
}
GetFlag reads a flag with its configuration in every environment.
func NewGetFlag ¶
func NewGetFlag(snapshots Snapshotter, store FlagReader, evaluations LastEvaluations) *GetFlag
NewGetFlag returns the handler.
func (*GetFlag) Handle ¶
func (h *GetFlag) Handle(ctx context.Context, project workspace.ProjectID, key string) (FlagView, error)
Handle returns project's flag with key, or not_found. The definition and the configurations are read in one snapshot, so they are never those of a flag deleted and created again in between.
type GetFlagConfiguration ¶
type GetFlagConfiguration struct {
// contains filtered or unexported fields
}
GetFlagConfiguration reads a flag's configuration in one environment.
func NewGetFlagConfiguration ¶
func NewGetFlagConfiguration(snapshots Snapshotter, store ConfigurationReader) *GetFlagConfiguration
NewGetFlagConfiguration returns the handler.
func (*GetFlagConfiguration) Handle ¶
func (h *GetFlagConfiguration) Handle(ctx context.Context, project workspace.ProjectID, flag, environment string, ) (flags.EnvironmentConfiguration, error)
Handle returns the configuration of project's flag keyed flag in the environment keyed environment, or not_found for either. The flag and the configuration are read in one snapshot, so the configuration is the flag found's.
type GetSegment ¶
type GetSegment struct {
// contains filtered or unexported fields
}
GetSegment reads one segment.
func NewGetSegment ¶
func NewGetSegment(store SegmentReader) *GetSegment
NewGetSegment returns the handler.
type KillFlag ¶
type KillFlag struct {
// contains filtered or unexported fields
}
KillFlag switches a flag off in one environment at once: the kill switch.
func (*KillFlag) Handle ¶
func (h *KillFlag) Handle(ctx context.Context, cmd KillFlagCommand) (flags.EnvironmentConfiguration, bool, error)
Handle switches the flag off and returns the configuration as it is after, and whether it was on. A flag already off changes nothing and records nothing, so a repeated click is harmless; otherwise the audit entry carries the reason and is marked as a kill switch.
type KillFlagCommand ¶
type KillFlagCommand struct {
Configuration ConfigurationCommand
Reason *string
}
KillFlagCommand is a kill switch of the configuration Configuration names, with the reason given, if any. The version it names is never judged: whoever stops an incident must not be refused for an old page.
type LastEvaluations ¶ added in v0.2.0
type LastEvaluations interface {
// LastEvaluated returns when each of fs was last evaluated, by flag
// then environment key; a flag never evaluated in an environment is
// absent.
LastEvaluated(ctx context.Context, fs []flags.FlagID) (map[flags.FlagID]map[string]time.Time, error)
}
LastEvaluations reads when SDKs last evaluated flags, which the events context learns from evaluation summaries and exposures.
type ListFlags ¶
type ListFlags struct {
// contains filtered or unexported fields
}
ListFlags lists a project's flags a page at a time.
func NewListFlags ¶
func NewListFlags(snapshots Snapshotter, environments Environments, store FlagLister, evaluations LastEvaluations) *ListFlags
NewListFlags returns the handler, which finds the environments a page names in environments.
func (*ListFlags) Handle ¶
func (h *ListFlags) Handle(ctx context.Context, project workspace.ProjectID, p FlagPage) ([]ListedFlag, *FlagCursor, error)
Handle returns one page of project's flags and the cursor of the next, nil on the last. Paging by the sort's own values, a flag created meanwhile never shifts a page. The environments are found and the flags read in one snapshot, at most two queries whatever the page's size; a comparison reads past the page's end in the same query, skipping the flags whose configurations carry the same ruleset in both environments, since only the domain judges that. When each flag was last evaluated is read in one more query.
type ListSegmentUsages ¶
type ListSegmentUsages struct {
// contains filtered or unexported fields
}
ListSegmentUsages reads where a segment is used.
func NewListSegmentUsages ¶
func NewListSegmentUsages(snapshots Snapshotter, store SegmentReader) *ListSegmentUsages
NewListSegmentUsages returns the handler.
func (*ListSegmentUsages) Handle ¶
func (h *ListSegmentUsages) Handle(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)
Handle returns every flag and environment whose rules name project's segment key, or not_found for a segment the project does not have. The segment and its usages are read in one snapshot, so the usages are those of the segment found.
type ListSegments ¶
type ListSegments struct {
// contains filtered or unexported fields
}
ListSegments lists a project's segments.
func NewListSegments ¶
func NewListSegments(snapshots Snapshotter, store SegmentLister) *ListSegments
NewListSegments returns the handler.
func (*ListSegments) Handle ¶
func (h *ListSegments) Handle(ctx context.Context, project workspace.ProjectID) ([]ListedSegment, error)
Handle returns project's segments by key, each with how many flags' rules name it. The segments and the counts are read in one snapshot, so a count is never that of a segment deleted and created again in between, and the counts of the whole list cost one query.
type ListStaleFlags ¶ added in v0.2.0
type ListStaleFlags struct {
// contains filtered or unexported fields
}
ListStaleFlags lists a project's stale flags a page at a time.
func NewListStaleFlags ¶ added in v0.2.0
func NewListStaleFlags(d StaleDeps) *ListStaleFlags
NewListStaleFlags returns the handler.
func (*ListStaleFlags) Handle ¶ added in v0.2.0
func (h *ListStaleFlags) Handle(ctx context.Context, project workspace.ProjectID, p StaleFlagPage) ([]StaleFlag, *string, error)
Handle returns one page of project's stale flags, and the key to start the next page after, nil on the last page. Whether a flag is stale is judged by the domain from facts several contexts hold, so flags are read by key in batches and judged until the page is full, all in one snapshot.
type ListedFlag ¶
ListedFlag is a flag's definition with its flag state in every environment, by the environments' order.
type ListedSegment ¶
ListedSegment is a segment with how many flags' rules name it.
type Owners ¶
type Owners interface {
// MayOwn reports whether member is an active member holding a grant
// in project, or an instance admin.
MayOwn(ctx context.Context, project workspace.ProjectID, member access.MemberID) (bool, error)
}
Owners judges who may own a flag.
type ProjectLocker ¶
type ProjectLocker interface {
// LockProject locks the project's row, or answers ErrNotFound when
// there is none.
LockProject(ctx context.Context, project workspace.ProjectID) error
}
ProjectLocker locks a project's row for the unit of work. Every write of the context takes this lock first and no other, so the writes of a project are made one at a time in one lock order.
type QueriedFlag ¶
type QueriedFlag struct {
ListedFlag
Compared [2]flags.Configuration
}
QueriedFlag is a flag the store lists, with its configurations in the two environments the query compares when it compares two.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is what every command handler of the context runs on besides its store: the clock a change is timed by, the source its identifiers are drawn from, and the audit log it is recorded in, so a change and its entry carry the same instant.
type ReferentReader ¶
type ReferentReader interface {
// ProjectFlags returns every flag of project, archived ones included.
ProjectFlags(ctx context.Context, project workspace.ProjectID) ([]flags.Flag, error)
// Segments returns the project's segments by key.
Segments(ctx context.Context, project workspace.ProjectID) ([]flags.Segment, error)
// Requirements returns, by flag key, the keys of the flags each flag's
// configuration in environment requires, archived flags included.
Requirements(ctx context.Context, environment workspace.EnvironmentID) (flags.Requirements, error)
// ProjectExperiments returns every experiment of project, whatever its
// status.
ProjectExperiments(ctx context.Context, project workspace.ProjectID) ([]flags.ExperimentRef, error)
}
ReferentReader reads what a configuration may name.
type ReferrerReader ¶ added in v0.2.0
type ReferrerReader interface {
// SegmentReferrers returns the flags of project whose rules name the
// segment key in some environment, archived flags included, each once.
SegmentReferrers(ctx context.Context, project workspace.ProjectID, key string) ([]flags.FlagID, error)
}
ReferrerReader reads which flags name a segment.
type RegenerateSalt ¶
type RegenerateSalt struct {
// contains filtered or unexported fields
}
RegenerateSalt gives a rollout a new salt, on purpose: its units are bucketed afresh.
func NewRegenerateSalt ¶
func NewRegenerateSalt(d ConfigurationDeps) *RegenerateSalt
NewRegenerateSalt returns the handler.
func (*RegenerateSalt) Handle ¶
func (h *RegenerateSalt) Handle(ctx context.Context, cmd RegenerateSaltCommand) (flags.EnvironmentConfiguration, error)
Handle regenerates the salt and returns the configuration as it is after. The rule is judged first, then the version the write was based on, as for any write.
type RegenerateSaltCommand ¶
type RegenerateSaltCommand struct {
Configuration ConfigurationCommand
Rule flags.RuleID
}
RegenerateSaltCommand names the rule whose rollout gets a new salt, in the configuration Configuration names.
type RemoveOverride ¶
type RemoveOverride struct {
// contains filtered or unexported fields
}
RemoveOverride removes the override of one unit without replacing the rest of a configuration.
func NewRemoveOverride ¶
func NewRemoveOverride(d ConfigurationDeps) *RemoveOverride
NewRemoveOverride returns the handler.
func (*RemoveOverride) Handle ¶
func (h *RemoveOverride) Handle(ctx context.Context, cmd RemoveOverrideCommand) (flags.EnvironmentConfiguration, error)
Handle removes the override and returns the configuration as it is after; not_found when the unit has none.
type RemoveOverrideCommand ¶
type RemoveOverrideCommand struct {
Configuration ConfigurationCommand
UnitType, UnitID string
}
RemoveOverrideCommand names the unit whose override to remove from the configuration Configuration names, whose version is never judged.
type ReplaceConfiguration ¶
type ReplaceConfiguration struct {
// contains filtered or unexported fields
}
ReplaceConfiguration replaces a flag's configuration in one environment as a whole.
func NewReplaceConfiguration ¶
func NewReplaceConfiguration(d ReplaceConfigurationDeps) *ReplaceConfiguration
NewReplaceConfiguration returns the handler.
func (*ReplaceConfiguration) Handle ¶
func (h *ReplaceConfiguration) Handle(ctx context.Context, cmd ReplaceConfigurationCommand) (flags.EnvironmentConfiguration, error)
Handle replaces the configuration and returns it as it is after. The configuration is validated first, against the project's flags, segments and declarations and every flag's requirements in the environment, all read under the project's lock so they hold when the write commits; then the version it was based on is judged. A replace whose only change to what a ruleset carries is switching the flag on or off is recorded as that switch.
type ReplaceConfigurationCommand ¶
type ReplaceConfigurationCommand struct {
Configuration ConfigurationCommand
Input flags.ConfigurationInput
}
ReplaceConfigurationCommand is the configuration to write whole in place of the one Configuration names.
type ReplaceConfigurationDeps ¶
type ReplaceConfigurationDeps struct {
Tx Transactor
Projects ProjectLocker
Declarations Declarations
Store ConfigurationReplacer
Rulesets Rulesets
Recorder Recorder
}
ReplaceConfigurationDeps are what ReplaceConfiguration runs on.
type RestoreFlag ¶
type RestoreFlag struct {
// contains filtered or unexported fields
}
RestoreFlag brings an archived flag back to SDKs as it was archived.
func NewRestoreFlag ¶
func NewRestoreFlag(d ArchivalDeps) *RestoreFlag
NewRestoreFlag returns the handler.
func (*RestoreFlag) Handle ¶
func (h *RestoreFlag) Handle(ctx context.Context, cmd FlagCommand) (FlagView, error)
Handle restores the flag and returns it; a flag that is not archived stays as it is and nothing is recorded.
type RevertConfiguration ¶
type RevertConfiguration struct {
// contains filtered or unexported fields
}
RevertConfiguration writes a flag's configuration in one environment again as an earlier version of it was.
func NewRevertConfiguration ¶
func NewRevertConfiguration(d RevertConfigurationDeps) *RevertConfiguration
NewRevertConfiguration returns the handler.
func (*RevertConfiguration) ApplyRevert ¶ added in v0.2.0
func (h *RevertConfiguration) ApplyRevert(ctx context.Context, project workspace.ProjectID, flag, environment string, version, baseVersion int64, by *access.MemberID, req governance.Request, ) error
ApplyRevert reverts the configuration of project's flag keyed flag in the environment keyed environment to version, based on its version baseVersion, in the unit of work ctx carries, which joins the change request's application: as a direct revert is, written whole and audited flag.reverted. by is the member applying, nil for a project token or the system; req is who makes the change. A refusal rolls the application back.
func (*RevertConfiguration) Handle ¶
func (h *RevertConfiguration) Handle(ctx context.Context, cmd RevertConfigurationCommand) (flags.EnvironmentConfiguration, error)
Handle reverts the configuration and returns it as it is after. The version is looked up only among the audit entries of this flag, by its identifier, in this environment, so a flag or environment created again with a key once used never inherits an older one's history. The recorded document is written whole and validated as a replace is, against what the project has now; then the version the write was based on is judged.
func (*RevertConfiguration) ProposeRevert ¶ added in v0.2.0
func (h *RevertConfiguration) ProposeRevert(ctx context.Context, project workspace.ProjectID, flag, environment string, version int64, ) (flags.Flag, flags.EnvironmentConfiguration, flags.Configuration, error)
ProposeRevert returns project's flag keyed flag, its saved configuration in the environment keyed environment, and what reverting it to version would write, with the refusals a revert gets: not_found, archived, version_not_found, experiment_rules_changed, invalid_configuration. It writes nothing: a change request proposes the revert, and fills what it proposes from it.
type RevertConfigurationCommand ¶
type RevertConfigurationCommand struct {
Configuration ConfigurationCommand
Version int64
}
RevertConfigurationCommand reverts the configuration Configuration names to its version Version.
type RevertConfigurationDeps ¶
type RevertConfigurationDeps struct {
Tx Transactor
Projects ProjectLocker
Declarations Declarations
Store ConfigurationReplacer
History ConfigurationHistory
Rulesets Rulesets
Recorder Recorder
}
RevertConfigurationDeps are what RevertConfiguration runs on.
type Rulesets ¶
type Rulesets interface {
// Project marks the ruleset of every environment of project changed.
Project(ctx context.Context, project workspace.ProjectID) error
// Environment marks the ruleset of environment changed.
Environment(ctx context.Context, environment workspace.EnvironmentID) error
}
Rulesets marks the rulesets a write changed, in the write's unit of work.
type RunningExperiments ¶ added in v0.2.0
type RunningExperiments interface {
// RunningExperimentsOf returns project's running experiments.
RunningExperimentsOf(ctx context.Context, project workspace.ProjectID) ([]experiments.Experiment, error)
}
RunningExperiments reads a project's running experiments, which the experiments context holds.
type SegmentCommand ¶
type SegmentCommand struct {
Project workspace.ProjectID
Key string
Expected precondition.Version
Request governance.Request
}
SegmentCommand names one segment of a project and the version of it a write is based on.
type SegmentCreator ¶
type SegmentCreator interface {
// CreateSegment refuses a key the project uses as already_exists.
CreateSegment(ctx context.Context, s flags.Segment) error
}
SegmentCreator stores a new segment.
type SegmentDeleter ¶
type SegmentDeleter interface {
SegmentByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
// SegmentUsages returns one reference per flag and environment whose
// rules name the segment key, archived flags included.
SegmentUsages(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)
DeleteSegment(ctx context.Context, segment flags.SegmentID) error
}
SegmentDeleter deletes a segment no rule names.
type SegmentLister ¶
type SegmentLister interface {
// Segments returns the project's segments by key.
Segments(ctx context.Context, project workspace.ProjectID) ([]flags.Segment, error)
// SegmentUsageCounts returns, by segment key, how many flags' rules
// name it, archived flags included; a key no rule names is absent.
SegmentUsageCounts(ctx context.Context, project workspace.ProjectID) (map[string]int, error)
}
SegmentLister lists a project's segments with how much they are used.
type SegmentReader ¶
type SegmentReader interface {
SegmentByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
// SegmentUsages returns one reference per flag and environment whose
// rules name the segment key, archived flags included, by flag key and
// then environment order.
SegmentUsages(ctx context.Context, project workspace.ProjectID, key string) ([]flags.Reference, error)
}
SegmentReader reads one segment of a project and where it is used.
type SegmentReferrers ¶ added in v0.2.0
type SegmentReferrers struct {
// contains filtered or unexported fields
}
SegmentReferrers reads which flags name a segment, for the governance context to tell which writes move a change request to its definition.
func NewSegmentReferrers ¶ added in v0.2.0
func NewSegmentReferrers(store ReferrerReader) *SegmentReferrers
NewSegmentReferrers returns the query.
func (*SegmentReferrers) SegmentReferrers ¶ added in v0.2.0
func (h *SegmentReferrers) SegmentReferrers(ctx context.Context, project workspace.ProjectID, key string, ) ([]flags.FlagID, error)
SegmentReferrers returns the flags of project whose rules name the segment key in some environment, archived flags included, each once, read in the unit of work ctx carries; none for a segment nothing names or the project does not have.
type SegmentUpdater ¶
type SegmentUpdater interface {
// SegmentByKey returns project's segment with key, or ErrNotFound.
SegmentByKey(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
UpdateSegment(ctx context.Context, s flags.Segment) error
}
SegmentUpdater stores a segment's changes.
type SetOverride ¶
type SetOverride struct {
// contains filtered or unexported fields
}
SetOverride pins a variation for one unit without replacing the rest of a configuration.
func NewSetOverride ¶
func NewSetOverride(d SetOverrideDeps) *SetOverride
NewSetOverride returns the handler.
func (*SetOverride) Handle ¶
func (h *SetOverride) Handle(ctx context.Context, cmd SetOverrideCommand) (flags.EnvironmentConfiguration, error)
Handle sets the override and returns the configuration as it is after.
type SetOverrideCommand ¶
type SetOverrideCommand struct {
Configuration ConfigurationCommand
Override flags.OverrideInput
}
SetOverrideCommand is the override to set in the configuration Configuration names. The version it names is never judged: one unit's override never conflicts with an edit of the rest.
type SetOverrideDeps ¶
type SetOverrideDeps struct {
Tx Transactor
Projects ProjectLocker
Declarations Declarations
Store ConfigurationWriter
Rulesets Rulesets
Recorder Recorder
}
SetOverrideDeps are what SetOverride runs on.
type Snapshotter ¶
type Snapshotter interface {
Snapshot(ctx context.Context, fn func(ctx context.Context) error) error
}
Snapshotter runs a query of several statements on one consistent view, so what it answers never mixes the states before and after a write committed between its statements.
type StaleDeps ¶ added in v0.2.0
type StaleDeps struct {
Snapshots Snapshotter
Store UnarchivedFlagReader
Evaluations LastEvaluations
Summaries SummaryDays
Experiments RunningExperiments
Owners Owners
Clock clock.Clock
}
StaleDeps are what ListStaleFlags reads.
type StaleFlag ¶ added in v0.2.0
StaleFlag is a stale flag with its configurations, when SDKs last evaluated it, and why it is stale.
type StaleFlagPage ¶ added in v0.2.0
type StaleFlagPage struct {
// Reasons lists only the flags stale for one of them; empty for every
// stale flag.
Reasons []flags.StaleReason
// After is the key the page starts after, "" for the first page.
After string
Limit int
}
StaleFlagPage asks for one page of a project's stale flags, by key in byte order.
type StateFilter ¶
type StateFilter string
StateFilter is a flag state flags are listed by within one environment.
const ( StateOn StateFilter = "on" StateOff StateFilter = "off" StateRules StateFilter = "rules" StateRollout StateFilter = "rollout" // StateExperiment lists the flags with a rule serving an experiment. StateExperiment StateFilter = "experiment" )
The flag states flags are listed by: on, off, with rules whether on or off, with a rule serving a rollout, with a rule serving an experiment.
type SummaryDays ¶ added in v0.2.0
type SummaryDays interface {
// LastSummaryDay returns the latest UTC day project received an SDK's
// evaluation summary, nil for never.
LastSummaryDay(ctx context.Context, project workspace.ProjectID) (*time.Time, error)
}
SummaryDays reads when a project last received an SDK's evaluation summary, which the events context counts.
type Transactor ¶
Transactor runs a unit of work.
type UnarchivedFlagReader ¶ added in v0.2.0
type UnarchivedFlagReader interface {
// UnarchivedFlags returns up to limit of project's flags that are not
// archived, each with its configuration in every environment, by key
// in byte order, those whose key is greater than after when it is not
// "".
UnarchivedFlags(ctx context.Context, project workspace.ProjectID, after string, limit int) ([]FlagView, error)
}
UnarchivedFlagReader reads a project's flags that are not archived.
type UpdateFlag ¶
type UpdateFlag struct {
// contains filtered or unexported fields
}
UpdateFlag changes a flag's definition.
func NewUpdateFlag ¶
func NewUpdateFlag(d UpdateFlagDeps) *UpdateFlag
NewUpdateFlag returns the handler.
func (*UpdateFlag) Apply ¶ added in v0.2.0
func (h *UpdateFlag) Apply(ctx context.Context, project workspace.ProjectID, key string, change flags.FlagChange, baseVersion int64, req governance.Request, ) error
Apply makes change to project's flag keyed key, based on its version baseVersion, in the unit of work ctx carries, which joins a change request's application: checked again as Handle checks it, since what it names may be gone since it was approved, and recorded as Handle records it. Whether the write may change a protected environment is the bypass ctx carries, as for every write.
func (*UpdateFlag) Current ¶ added in v0.2.0
func (h *UpdateFlag) Current(ctx context.Context, project workspace.ProjectID, key string) (flags.Flag, error)
Current returns project's flag keyed key, or not_found.
func (*UpdateFlag) Handle ¶
func (h *UpdateFlag) Handle(ctx context.Context, cmd UpdateFlagCommand) (FlagView, error)
Handle applies the change and returns the flag as it is after it. The change is validated first, then judged against the version it was based on, then against what still names a variation it removes, in the flag's configurations, other flags' prerequisites or an experiment's weights; a change to the values the flag already has stores and records nothing. A change to what a ruleset carries moves every environment's ruleset on.
func (*UpdateFlag) Propose ¶ added in v0.2.0
func (h *UpdateFlag) Propose(ctx context.Context, project workspace.ProjectID, key string, change flags.FlagChange, ) (flags.Flag, flags.Flag, error)
Propose returns project's flag keyed key, and the flag change would leave it as, checked as Handle checks it, with the same refusals; it stores and records nothing. It reads in the unit of work ctx carries, whose caller holds the project's lock.
type UpdateFlagCommand ¶
type UpdateFlagCommand struct {
Project workspace.ProjectID
Key string
Change flags.FlagChange
Owner *access.MemberID
Expected precondition.Version
Request governance.Request
}
UpdateFlagCommand is a change to the flag Key of Project, based on the version Expected names. Owner is the new owner the change names, if any.
type UpdateFlagDeps ¶
type UpdateFlagDeps struct {
Tx Transactor
Projects ProjectLocker
Store DefinitionUpdater
Owners Owners
Rulesets Rulesets
Recorder Recorder
Evaluations LastEvaluations
}
UpdateFlagDeps are what UpdateFlag runs on.
type UpdateSegment ¶
type UpdateSegment struct {
// contains filtered or unexported fields
}
UpdateSegment changes a segment.
func NewUpdateSegment ¶
func NewUpdateSegment(d UpdateSegmentDeps) *UpdateSegment
NewUpdateSegment returns the handler.
func (*UpdateSegment) Apply ¶ added in v0.2.0
func (h *UpdateSegment) Apply(ctx context.Context, project workspace.ProjectID, key string, change flags.SegmentChange, baseVersion int64, req governance.Request, ) error
Apply makes change to project's segment keyed key, based on its version baseVersion, in the unit of work ctx carries, which joins a change request's application: checked again as Handle checks it and recorded as Handle records it. Whether the write may change a protected environment is the bypass ctx carries, as for every write.
func (*UpdateSegment) Current ¶ added in v0.2.0
func (h *UpdateSegment) Current(ctx context.Context, project workspace.ProjectID, key string) (flags.Segment, error)
Current returns project's segment keyed key, or not_found.
func (*UpdateSegment) Handle ¶
func (h *UpdateSegment) Handle(ctx context.Context, cmd UpdateSegmentCommand) (flags.Segment, error)
Handle applies the change, validated first and then judged against the version it was based on, and returns the segment as it is after it; a change to the values it already has stores and records nothing. A change to its conditions or private switch moves every environment's ruleset on.
func (*UpdateSegment) Propose ¶ added in v0.2.0
func (h *UpdateSegment) Propose(ctx context.Context, project workspace.ProjectID, key string, change flags.SegmentChange, ) (flags.Segment, flags.Segment, error)
Propose returns project's segment keyed key, and the segment change would leave it as, checked as Handle checks it, with the same refusals; it stores and records nothing. It reads in the unit of work ctx carries, whose caller holds the project's lock.
type UpdateSegmentCommand ¶
type UpdateSegmentCommand struct {
Project workspace.ProjectID
Key string
Change flags.SegmentChange
Expected precondition.Version
Request governance.Request
}
UpdateSegmentCommand is a change to the segment Key of Project, based on the version Expected names.
type UpdateSegmentDeps ¶
type UpdateSegmentDeps struct {
Tx Transactor
Projects ProjectLocker
Declarations Declarations
Store SegmentUpdater
Rulesets Rulesets
Recorder Recorder
}
UpdateSegmentDeps are what UpdateSegment runs on.
Source Files
¶
- apply_proposal.go
- archive_flag.go
- configuration.go
- configure_environment.go
- copy_configuration.go
- create_flag.go
- create_segment.go
- declarations.go
- definitions.go
- delete_flag.go
- delete_segment.go
- draft_configuration.go
- experiment_holders.go
- flags.go
- kill_flag.go
- queries.go
- regenerate_salt.go
- remove_override.go
- replace_configuration.go
- restore_flag.go
- revert_configuration.go
- segment_queries.go
- set_override.go
- stale_flags.go
- update_flag.go
- update_segment.go