workspace

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package workspace holds the use cases of the workspace context: projects, their environments, unit types and attributes.

Index

Constants

View Source
const ProjectPurgeBatch = 1000

ProjectPurgeBatch is how many rows one transaction of the purge deletes, so a large project's leftovers never hold locks or a transaction open for long.

Variables

View Source
var ErrNotFound = errors.New("workspace: not found")

ErrNotFound is what a store answers for an entity it does not hold.

Functions

This section is empty.

Types

type AttributeCreator

type AttributeCreator interface {
	DeclarationKeys
	CreateAttribute(ctx context.Context, attr workspace.Attribute) error
}

AttributeCreator stores a new attribute.

type AttributeDeleter

type AttributeDeleter interface {
	ProjectLocker
	AttributeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Attribute, error)
	DeleteAttribute(ctx context.Context, attribute workspace.AttributeID) error
}

AttributeDeleter deletes an attribute.

type AttributeReader

type AttributeReader interface {
	// Attributes returns the project's attributes by key.
	Attributes(ctx context.Context, project workspace.ProjectID) ([]workspace.Attribute, error)
	AttributeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Attribute, error)
}

AttributeReader reads a project's attributes.

type AttributeUpdater

type AttributeUpdater interface {
	// AttributeByKey returns the attribute, locking its row when lock is set,
	// or ErrNotFound.
	AttributeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Attribute, error)
	UpdateAttribute(ctx context.Context, attr workspace.Attribute) error
}

AttributeUpdater stores an attribute's changed name and description.

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 CreateAttribute

type CreateAttribute struct {
	// contains filtered or unexported fields
}

CreateAttribute declares an attribute in a project.

func NewCreateAttribute

func NewCreateAttribute(tx Transactor, store AttributeCreator, rulesets Rulesets, rec Recorder) *CreateAttribute

NewCreateAttribute returns the handler.

func (*CreateAttribute) Handle

Handle declares the attribute.

type CreateAttributeCommand

type CreateAttributeCommand struct {
	Project                workspace.ProjectID
	Key, Name, Description string
	Type                   workspace.AttributeType
	Request                governance.Request
}

CreateAttributeCommand names the attribute to declare.

type CreateEnvironment

type CreateEnvironment struct {
	// contains filtered or unexported fields
}

CreateEnvironment adds an environment to a project.

func NewCreateEnvironment

func NewCreateEnvironment(tx Transactor, store EnvironmentCreator, configure EnvironmentConfigurer, rec Recorder) *CreateEnvironment

NewCreateEnvironment returns the handler, which has configure set the new environment up for what the project already holds.

func (*CreateEnvironment) Handle

Handle adds the environment after the project's others, under the project's row lock so two created at once never share a place and no flag created meanwhile misses a configuration in it.

type CreateEnvironmentCommand

type CreateEnvironmentCommand struct {
	Project   workspace.ProjectID
	Key, Name string
	Caller    *access.MemberID
	Request   governance.Request
}

CreateEnvironmentCommand names the environment to add. Caller is the member adding it, nil for a project token.

type CreateProject

type CreateProject struct {
	// contains filtered or unexported fields
}

CreateProject creates a project with its default environments, unit types and standard attributes, so a new project is usable at once.

func NewCreateProject

func NewCreateProject(tx Transactor, store ProjectCreator, rec Recorder) *CreateProject

NewCreateProject returns the handler.

func (*CreateProject) Handle

Handle creates the project. Its creator receives no grant: only an instance admin creates projects, and they hold every permission in every project already.

type CreateProjectCommand

type CreateProjectCommand struct {
	Key, Name, Description string
	Request                governance.Request
}

CreateProjectCommand names the project to create.

type CreateUnitType

type CreateUnitType struct {
	// contains filtered or unexported fields
}

CreateUnitType declares a unit type in a project.

func NewCreateUnitType

func NewCreateUnitType(tx Transactor, store UnitTypeCreator, rulesets Rulesets, rec Recorder) *CreateUnitType

NewCreateUnitType returns the handler.

func (*CreateUnitType) Handle

Handle declares the unit type.

type CreateUnitTypeCommand

type CreateUnitTypeCommand struct {
	Project                workspace.ProjectID
	Key, Name, Description string
	Request                governance.Request
}

CreateUnitTypeCommand names the unit type to declare.

type DeclarationGuard

type DeclarationGuard interface {
	// RefuseReferenced answers in_use, listing what names the declaration
	// keyed key in project, or nil when nothing does, under the project's
	// lock the caller holds.
	RefuseReferenced(ctx context.Context, project workspace.ProjectID, key string) error
}

DeclarationGuard refuses to delete a unit type or attribute that rules, rollouts, overrides or segments still name, which the flags context knows.

type DeclarationKeys

type DeclarationKeys interface {
	ProjectLocker
	DeclarationKeyTaken(ctx context.Context, project workspace.ProjectID, key string) (bool, error)
}

DeclarationKeys tells whether a project's unit types or attributes use a key. No constraint spans the two, so a caller asks under the project's row lock.

type DeclarationUsages

type DeclarationUsages 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)
}

DeclarationUsages counts what names a project's unit types and attributes, which the flags context knows.

type DeleteAttribute

type DeleteAttribute struct {
	// contains filtered or unexported fields
}

DeleteAttribute deletes an attribute.

func NewDeleteAttribute

func NewDeleteAttribute(tx Transactor, store AttributeDeleter, guard DeclarationGuard, rulesets Rulesets, rec Recorder) *DeleteAttribute

NewDeleteAttribute returns the handler, which has guard refuse an attribute something still names.

func (*DeleteAttribute) Handle

Handle deletes the attribute unless it is standard or a rule or segment still names it, which every environment's ruleset then no longer declares. It holds the project's lock, which every write naming an attribute takes too, so no write starts naming it between the check and the deletion.

type DeleteAttributeCommand

type DeleteAttributeCommand struct {
	Project  workspace.ProjectID
	Key      string
	Expected precondition.Version
	Request  governance.Request
}

DeleteAttributeCommand names the attribute to delete and the version of it the deletion is based on.

type DeleteEnvironment

type DeleteEnvironment struct {
	// contains filtered or unexported fields
}

DeleteEnvironment deletes an environment.

func NewDeleteEnvironment

func NewDeleteEnvironment(tx Transactor, store EnvironmentDeleter, rec Recorder) *DeleteEnvironment

NewDeleteEnvironment returns the handler.

func (*DeleteEnvironment) Handle

Handle deletes the environment. The project's row is locked first, so two deletions at once cannot remove its last two environments.

type DeleteEnvironmentCommand

type DeleteEnvironmentCommand struct {
	Project  workspace.ProjectID
	Key      string
	Expected precondition.Version
	Request  governance.Request
}

DeleteEnvironmentCommand names the environment to delete and the version of it the deletion is based on.

type DeleteProject added in v0.2.0

type DeleteProject struct {
	// contains filtered or unexported fields
}

DeleteProject deletes a project with everything in it.

func NewDeleteProject added in v0.2.0

func NewDeleteProject(tx Transactor, store ProjectDeleter, rec Recorder) *DeleteProject

NewDeleteProject returns the handler.

func (*DeleteProject) Handle added in v0.2.0

Handle deletes the project in one unit of work, so its key is free for a new project once it commits. The project's row is locked first: every write in the project takes that lock, so none is half done when the rows go. The deletion is an entry of the instance, not of the project, since it is what the project's remaining entries are read against once the project is gone; it names the project's identifier, key and name. It ends the project's change requests too, which go with the rows, with no entry of their own: every one of them ends for the same reason.

type DeleteProjectCommand added in v0.2.0

type DeleteProjectCommand struct {
	Project  workspace.ProjectID
	Expected precondition.Version
	Request  governance.Request
}

DeleteProjectCommand names the project to delete and the version of it the deletion is based on.

type DeleteUnitType

type DeleteUnitType struct {
	// contains filtered or unexported fields
}

DeleteUnitType deletes a unit type.

func NewDeleteUnitType

func NewDeleteUnitType(tx Transactor, store UnitTypeDeleter, guard DeclarationGuard, rulesets Rulesets, rec Recorder) *DeleteUnitType

NewDeleteUnitType returns the handler, which has guard refuse a unit type something still names.

func (*DeleteUnitType) Handle

Handle deletes the unit type unless a rule, rollout, override or segment still names it, which every environment's ruleset then no longer declares. It holds the project's lock, which every write naming a unit type takes too, so no write starts naming it between the check and the deletion.

type DeleteUnitTypeCommand

type DeleteUnitTypeCommand struct {
	Project  workspace.ProjectID
	Key      string
	Expected precondition.Version
	Request  governance.Request
}

DeleteUnitTypeCommand names the unit type to delete and the version of it the deletion is based on.

type EnvironmentConfigurer

type EnvironmentConfigurer interface {
	// ConfigureEnvironment configures e as written by by, the member
	// creating it (nil for a project token), in the unit of work ctx
	// carries.
	ConfigureEnvironment(ctx context.Context, e workspace.Environment, by *access.MemberID) error
}

EnvironmentConfigurer configures what a project holds in one of its environments, such as every flag's configuration, as the environment is created.

type EnvironmentCreator

type EnvironmentCreator interface {
	ProjectLocker
	// NextSortOrder returns the sort order after the project's others.
	NextSortOrder(ctx context.Context, project workspace.ProjectID) (int, error)
	// CreateEnvironment refuses a key the project uses as already_exists.
	CreateEnvironment(ctx context.Context, e workspace.Environment) error
}

EnvironmentCreator stores a new environment after its project's others.

type EnvironmentDeleter

type EnvironmentDeleter interface {
	ProjectLocker
	EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Environment, error)
	CountEnvironments(ctx context.Context, project workspace.ProjectID) (int, error)
	DeleteEnvironment(ctx context.Context, environment workspace.EnvironmentID) error
}

EnvironmentDeleter deletes an environment unless it is its project's last or protected.

type EnvironmentReader

type EnvironmentReader interface {
	// Environments returns the project's environments by sort order.
	Environments(ctx context.Context, project workspace.ProjectID) ([]workspace.Environment, error)
	EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Environment, error)
}

EnvironmentReader reads a project's environments.

type EnvironmentUpdater

type EnvironmentUpdater interface {
	ProjectLocker
	// EnvironmentByKey returns the environment, locking its row when lock is
	// set, or ErrNotFound.
	EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Environment, error)
	UpdateEnvironment(ctx context.Context, e workspace.Environment) error
}

EnvironmentUpdater stores an environment's changed name or protection.

type FindProject

type FindProject struct {
	// contains filtered or unexported fields
}

FindProject finds a project by the key a request names.

func NewFindProject

func NewFindProject(store ProjectFinder) *FindProject

NewFindProject returns the handler.

func (*FindProject) Handle

func (h *FindProject) Handle(ctx context.Context, key string) (workspace.Project, error)

Handle returns the project with key, or ErrNotFound.

type Get

type Get[T any] struct {
	// contains filtered or unexported fields
}

Get finds one thing a project holds by its key, such as an environment.

func NewGetAttribute

func NewGetAttribute(store AttributeReader) *Get[workspace.Attribute]

NewGetAttribute returns the query finding an attribute by key.

func NewGetEnvironment

func NewGetEnvironment(store EnvironmentReader) *Get[workspace.Environment]

NewGetEnvironment returns the query finding an environment by key.

func NewGetUnitType

func NewGetUnitType(store UnitTypeReader) *Get[workspace.UnitType]

NewGetUnitType returns the query finding a unit type by key.

func (*Get[T]) Handle

func (h *Get[T]) Handle(ctx context.Context, project workspace.ProjectID, key string) (T, error)

Handle returns project's thing with key, or not_found.

type ImportStore added in v0.3.0

ImportStore is what the import writes a project's declarations with.

type Importer added in v0.3.0

type Importer struct {
	// contains filtered or unexported fields
}

Importer writes the entities of a project document that the workspace context owns. It is the import's port into the context: every method runs the context's own validation, writes the entity and records the audit entry a direct write records, in the unit of work the caller's context carries, which also holds the project's row, so the version it reads of an entity is the one its write is based on. It moves no ruleset on: the import does that once per environment when it is done.

func NewImporter added in v0.3.0

func NewImporter(tx Transactor, store ImportStore, configure EnvironmentConfigurer, rec Recorder) *Importer

NewImporter returns the importer writing to store and recording through rec, which has configure give an environment it creates in a project that has flags a configuration of each.

func (*Importer) CreateAttribute added in v0.3.0

func (i *Importer) CreateAttribute(ctx context.Context, project workspace.ProjectID, key, name, description string,
	typ workspace.AttributeType, req governance.Request,
) (workspace.Attribute, error)

CreateAttribute declares an attribute of project, refusing a key a unit type or attribute of the project has, the standard attributes included.

func (*Importer) CreateEnvironment added in v0.3.0

func (i *Importer) CreateEnvironment(ctx context.Context, project workspace.ProjectID, key, name string, protected bool,
	sortOrder int, by *access.MemberID, req governance.Request,
) (workspace.Environment, error)

CreateEnvironment creates an environment of project at sortOrder, protected or not as the document says: a new environment has nothing to keep protected, so the document's value is taken. Every flag the project has is configured in it, switched off, as written by by, the member importing.

func (*Importer) CreateProject added in v0.3.0

func (i *Importer) CreateProject(ctx context.Context, key, name, description string, req governance.Request) (workspace.Project, error)

CreateProject creates a project holding only what every project holds, the standard attributes: the document adds the rest. A key in use is already_exists.

func (*Importer) CreateUnitType added in v0.3.0

func (i *Importer) CreateUnitType(ctx context.Context, project workspace.ProjectID, key, name, description string,
	req governance.Request,
) (workspace.UnitType, error)

CreateUnitType declares a unit type of project, refusing a key a unit type or attribute of the project has.

func (*Importer) UpdateAttribute added in v0.3.0

func (i *Importer) UpdateAttribute(ctx context.Context, project workspace.ProjectID, key, name, description string,
	req governance.Request,
) (bool, error)

UpdateAttribute renames an attribute or changes its description as an ordinary request does, and says whether that changed anything.

func (*Importer) UpdateEnvironment added in v0.3.0

func (i *Importer) UpdateEnvironment(ctx context.Context, project workspace.ProjectID, key, name string,
	req governance.Request,
) (bool, error)

UpdateEnvironment renames an environment as an ordinary request does, and says whether that changed anything. Whether it is protected is not an import's to change.

func (*Importer) UpdateProject added in v0.3.0

func (i *Importer) UpdateProject(ctx context.Context, project workspace.ProjectID, name, description string,
	req governance.Request,
) (workspace.Project, bool, error)

UpdateProject changes a project's name and description as an ordinary request does, and returns the project as it is, and whether that changed anything.

func (*Importer) UpdateUnitType added in v0.3.0

func (i *Importer) UpdateUnitType(ctx context.Context, project workspace.ProjectID, key, name, description string,
	req governance.Request,
) (bool, error)

UpdateUnitType renames a unit type or changes its description as an ordinary request does, and says whether that changed anything.

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

List lists what a project holds of one kind, such as its environments.

func NewListEnvironments

func NewListEnvironments(store EnvironmentReader) *List[workspace.Environment]

NewListEnvironments returns the query listing a project's environments.

func (*List[T]) Handle

func (h *List[T]) Handle(ctx context.Context, project workspace.ProjectID) ([]T, error)

Handle returns what project holds, in the kind's order.

type ListProjects

type ListProjects struct {
	// contains filtered or unexported fields
}

ListProjects lists the projects a caller works in.

func NewListProjects

func NewListProjects(store ProjectLister) *ListProjects

NewListProjects returns the handler.

func (*ListProjects) Handle

Handle returns the projects, ordered by key.

type ListProjectsQuery

type ListProjectsQuery struct {
	All  bool
	Only []workspace.ProjectID
}

ListProjectsQuery says which projects to list: every one, or those of Only.

type ListUsed

type ListUsed[T any] struct {
	// contains filtered or unexported fields
}

ListUsed lists a project's unit types or attributes with how many flags and segments name each.

func NewListAttributes

func NewListAttributes(snapshots Snapshotter, store AttributeReader, usages DeclarationUsages) *ListUsed[workspace.Attribute]

NewListAttributes returns the query listing a project's attributes, each with how many flags and segments usages counts naming it.

func NewListUnitTypes

func NewListUnitTypes(snapshots Snapshotter, store UnitTypeReader, usages DeclarationUsages) *ListUsed[workspace.UnitType]

NewListUnitTypes returns the query listing a project's unit types, each with how many flags and segments usages counts naming it.

func (*ListUsed[T]) Handle

func (h *ListUsed[T]) Handle(ctx context.Context, project workspace.ProjectID) ([]Used[T], error)

Handle returns project's declarations of the kind by key, each with its usage count. The declarations and the counts are read in one snapshot, so a count is never that of a declaration deleted and created again in between, and the counts of the whole list cost one query.

type ProjectCreator

type ProjectCreator interface {
	// CreateProject refuses a key in use as already_exists.
	CreateProject(ctx context.Context, p workspace.Project) error
	CreateEnvironment(ctx context.Context, e workspace.Environment) error
	CreateUnitType(ctx context.Context, u workspace.UnitType) error
	CreateAttribute(ctx context.Context, a workspace.Attribute) error
}

ProjectCreator stores a new project and its defaults.

type ProjectDeleter added in v0.2.0

type ProjectDeleter interface {
	ProjectLocker
	// DeleteProject deletes the project's row, and with it, by the
	// cascades of their foreign keys, every row that belongs to it.
	DeleteProject(ctx context.Context, project workspace.ProjectID) error
}

ProjectDeleter deletes a project with everything in it.

type ProjectFinder

type ProjectFinder interface {
	// ProjectByKey returns the project with key, or ErrNotFound.
	ProjectByKey(ctx context.Context, key string) (workspace.Project, error)
}

ProjectFinder finds a project by its key.

type ProjectLister

type ProjectLister interface {
	// Projects returns every project when all is set, else those of ids,
	// ordered by key.
	Projects(ctx context.Context, all bool, ids []workspace.ProjectID) ([]workspace.Project, error)
}

ProjectLister lists projects.

type ProjectLocker

type ProjectLocker interface {
	// LockProject returns the project, or ErrNotFound.
	LockProject(ctx context.Context, project workspace.ProjectID) (workspace.Project, error)
}

ProjectLocker locks a project's row for the unit of work, so the changes to a project and to what it holds are made one at a time.

type ProjectPurgeStore added in v0.2.0

type ProjectPurgeStore interface {
	// TryLockProjectPurge takes, until the transaction ends, the lock that
	// lets one replica purge at a time; false when another holds it.
	TryLockProjectPurge(ctx context.Context) (bool, error)
	// PurgeDeletedProjects deletes at most limit rows of projects that no
	// longer exist.
	PurgeDeletedProjects(ctx context.Context, limit int) (int, error)
}

ProjectPurgeStore deletes the rows deleted projects left in tables that have no foreign key to projects.

type ProjectUpdater

type ProjectUpdater interface {
	ProjectLocker
	UpdateProject(ctx context.Context, p workspace.Project) error
}

ProjectUpdater stores a project's changed name and description.

type ProtectedEnvironments added in v0.2.0

type ProtectedEnvironments struct {
	// contains filtered or unexported fields
}

ProtectedEnvironments reads which of a project's environments are protected, for the governance context to record what an approval covers.

func NewProtectedEnvironments added in v0.2.0

func NewProtectedEnvironments(store EnvironmentReader) *ProtectedEnvironments

NewProtectedEnvironments returns the query.

func (*ProtectedEnvironments) Protected added in v0.2.0

Protected returns project's protected environments by sort order, read in the unit of work ctx carries.

type PurgeDeletedProjects added in v0.2.0

type PurgeDeletedProjects struct {
	// contains filtered or unexported fields
}

PurgeDeletedProjects deletes what deleted projects left in tables without a foreign key to projects, which their deletion could not cascade to.

func NewPurgeDeletedProjects added in v0.2.0

func NewPurgeDeletedProjects(tx Transactor, store ProjectPurgeStore) *PurgeDeletedProjects

NewPurgeDeletedProjects returns the handler.

func (*PurgeDeletedProjects) Handle added in v0.2.0

func (h *PurgeDeletedProjects) Handle(ctx context.Context) (int, error)

Handle purges in batches, each in a transaction of its own holding the purge lock, until a batch finds less than a full batch to delete, and returns how many rows it deleted. When another replica holds the lock it leaves the work to it.

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.

func NewRecorder

func NewRecorder(audit AuditLog, c clock.Clock, ids *id.Source) Recorder

NewRecorder returns the recorder writing to audit, timing changes by c and identifying them from ids.

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

type SetEnvironmentProtection struct {
	// contains filtered or unexported fields
}

SetEnvironmentProtection protects an environment or stops protecting it. It is an operation apart from renaming, under a permission of its own, so that whoever may rename an environment cannot also lift the review its changes need.

func NewSetEnvironmentProtection added in v0.2.0

func NewSetEnvironmentProtection(tx Transactor, store EnvironmentUpdater, rulesets Rulesets, rec Recorder) *SetEnvironmentProtection

NewSetEnvironmentProtection returns the handler.

func (*SetEnvironmentProtection) Handle added in v0.2.0

Handle sets the protection, judged against the version it was based on, and returns the environment as it is after it; asking for the protection it already has stores and records nothing. The environment's ruleset moves with it, since SDKs read the protection from the ruleset to decide whether local overrides apply.

type SetEnvironmentProtectionCommand added in v0.2.0

type SetEnvironmentProtectionCommand struct {
	Project   workspace.ProjectID
	Key       string
	Protected bool
	Expected  precondition.Version
	Request   governance.Request
}

SetEnvironmentProtectionCommand protects the environment Key of Project or not as Protected says, based on the version Expected names.

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 Transactor

type Transactor interface {
	Within(ctx context.Context, fn func(ctx context.Context) error) error
}

Transactor runs a unit of work.

type UnitTypeCreator

type UnitTypeCreator interface {
	DeclarationKeys
	CreateUnitType(ctx context.Context, u workspace.UnitType) error
}

UnitTypeCreator stores a new unit type.

type UnitTypeDeleter

type UnitTypeDeleter interface {
	ProjectLocker
	UnitTypeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.UnitType, error)
	DeleteUnitType(ctx context.Context, unitType workspace.UnitTypeID) error
}

UnitTypeDeleter deletes a unit type.

type UnitTypeReader

type UnitTypeReader interface {
	// UnitTypes returns the project's unit types by key.
	UnitTypes(ctx context.Context, project workspace.ProjectID) ([]workspace.UnitType, error)
	UnitTypeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.UnitType, error)
}

UnitTypeReader reads a project's unit types.

type UnitTypeUpdater

type UnitTypeUpdater interface {
	// UnitTypeByKey returns the unit type, locking its row when lock is set,
	// or ErrNotFound.
	UnitTypeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.UnitType, error)
	UpdateUnitType(ctx context.Context, u workspace.UnitType) error
}

UnitTypeUpdater stores a unit type's changed name and description.

type UpdateAttribute

type UpdateAttribute struct {
	// contains filtered or unexported fields
}

UpdateAttribute renames an attribute or changes its description.

func NewUpdateAttribute

func NewUpdateAttribute(tx Transactor, store AttributeUpdater, rec Recorder) *UpdateAttribute

NewUpdateAttribute returns the handler.

func (*UpdateAttribute) Handle

Handle applies the change, validated first and then judged against the version it was based on, and returns the attribute as it is after it; a change to the values it already has stores and records nothing.

type UpdateAttributeCommand

type UpdateAttributeCommand struct {
	Project  workspace.ProjectID
	Key      string
	Change   workspace.AttributeChange
	Expected precondition.Version
	Request  governance.Request
}

UpdateAttributeCommand is a change to the attribute Key of Project, based on the version Expected names.

type UpdateEnvironment

type UpdateEnvironment struct {
	// contains filtered or unexported fields
}

UpdateEnvironment renames an environment.

func NewUpdateEnvironment

func NewUpdateEnvironment(tx Transactor, store EnvironmentUpdater, rec Recorder) *UpdateEnvironment

NewUpdateEnvironment returns the handler.

func (*UpdateEnvironment) Handle

Handle applies the change, validated first and then judged against the version it was based on, and returns the environment as it is after it; a change to the values it already has stores and records nothing.

type UpdateEnvironmentCommand

type UpdateEnvironmentCommand struct {
	Project  workspace.ProjectID
	Key      string
	Change   workspace.EnvironmentChange
	Expected precondition.Version
	Request  governance.Request
}

UpdateEnvironmentCommand is a change to the environment Key of Project, based on the version Expected names.

type UpdateProject

type UpdateProject struct {
	// contains filtered or unexported fields
}

UpdateProject renames a project or changes its description.

func NewUpdateProject

func NewUpdateProject(tx Transactor, store ProjectUpdater, rec Recorder) *UpdateProject

NewUpdateProject returns the handler.

func (*UpdateProject) Handle

Handle applies the change, validated first and then judged against the version it was based on, and returns the project as it is after it. A change to the values the project already has stores and records nothing.

type UpdateProjectCommand

type UpdateProjectCommand struct {
	Project  workspace.ProjectID
	Change   workspace.ProjectChange
	Expected precondition.Version
	Request  governance.Request
}

UpdateProjectCommand is a change to a project, based on the version Expected names.

type UpdateUnitType

type UpdateUnitType struct {
	// contains filtered or unexported fields
}

UpdateUnitType renames a unit type or changes its description.

func NewUpdateUnitType

func NewUpdateUnitType(tx Transactor, store UnitTypeUpdater, rec Recorder) *UpdateUnitType

NewUpdateUnitType returns the handler.

func (*UpdateUnitType) Handle

Handle applies the change, validated first and then judged against the version it was based on, and returns the unit type as it is after it; a change to the values it already has stores and records nothing.

type UpdateUnitTypeCommand

type UpdateUnitTypeCommand struct {
	Project  workspace.ProjectID
	Key      string
	Change   workspace.UnitTypeChange
	Expected precondition.Version
	Request  governance.Request
}

UpdateUnitTypeCommand is a change to the unit type Key of Project, based on the version Expected names.

type Used

type Used[T any] struct {
	Declaration T
	UsageCount  int
}

Used is a unit type or attribute with how many flags and segments name it.

Jump to

Keyboard shortcuts

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