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 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 DeleteFlag
- type DeleteFlagDeps
- type DeleteSegment
- type DeleteSegmentDeps
- type DependentFinder
- type DraftConfiguration
- type Environments
- 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 ListFlags
- type ListSegmentUsages
- type ListSegments
- type ListedFlag
- type ListedSegment
- type Owners
- type ProjectLocker
- type QueriedFlag
- type Recorder
- type ReferentReader
- type RegenerateSalt
- type RegenerateSaltCommand
- type RemoveOverride
- type RemoveOverrideCommand
- type ReplaceConfiguration
- type ReplaceConfigurationCommand
- type ReplaceConfigurationDeps
- type RestoreFlag
- type RevertConfiguration
- type RevertConfigurationCommand
- type RevertConfigurationDeps
- type Rulesets
- type SegmentCommand
- type SegmentCreator
- type SegmentDeleter
- type SegmentLister
- type SegmentReader
- type SegmentUpdater
- type SetOverride
- type SetOverrideCommand
- type SetOverrideDeps
- type Snapshotter
- type StateFilter
- type Transactor
- type UpdateFlag
- type UpdateFlagCommand
- type UpdateFlagDeps
- type UpdateSegment
- 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 ArchivalDeps ¶
type ArchivalDeps struct {
Tx Transactor
Projects ProjectLocker
Store FlagUpdater
Rulesets Rulesets
Recorder Recorder
}
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.
type ArchiveFlagDeps ¶
type ArchiveFlagDeps struct {
Tx Transactor
Projects ProjectLocker
Store FlagArchiver
Rulesets Rulesets
Recorder Recorder
}
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
}
DefinitionUpdater stores a flag's changed definition once nothing names what the change removes.
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) 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.
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 FlagArchiver ¶
type FlagArchiver interface {
FlagUpdater
DependentFinder
}
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 FlagUpdater ¶
FlagUpdater stores a flag's changed definition.
type FlagView ¶
type FlagView struct {
Flag flags.Flag
Configurations []flags.EnvironmentConfiguration
}
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) *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 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) *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.
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 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)
}
ReferentReader reads what a configuration may name.
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) 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.
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 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 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 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" )
The flag states flags are listed by: on, off, with rules whether on or off, with a rule serving a rollout.
type Transactor ¶
Transactor runs a unit of work.
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) 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 or other flags' prerequisites; 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.
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
}
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) 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.
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
¶
- archive_flag.go
- configuration.go
- configure_environment.go
- copy_configuration.go
- create_flag.go
- create_segment.go
- declarations.go
- delete_flag.go
- delete_segment.go
- draft_configuration.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
- update_flag.go
- update_segment.go