Documentation
¶
Overview ¶
Package workspace is the PostgreSQL repository of the workspace context: projects, their environments, unit types and attributes.
Index ¶
- func ProjectPurgeTables() []string
- type Store
- func (s *Store) AttributeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Attribute, error)
- func (s *Store) Attributes(ctx context.Context, project workspace.ProjectID) ([]workspace.Attribute, error)
- func (s *Store) CountEnvironments(ctx context.Context, project workspace.ProjectID) (int, error)
- func (s *Store) CreateAttribute(ctx context.Context, a workspace.Attribute) error
- func (s *Store) CreateEnvironment(ctx context.Context, e workspace.Environment) error
- func (s *Store) CreateProject(ctx context.Context, p workspace.Project) error
- func (s *Store) CreateUnitType(ctx context.Context, u workspace.UnitType) error
- func (s *Store) DeclarationKeyTaken(ctx context.Context, project workspace.ProjectID, key string) (bool, error)
- func (s *Store) DeleteAttribute(ctx context.Context, attribute workspace.AttributeID) error
- func (s *Store) DeleteEnvironment(ctx context.Context, environment workspace.EnvironmentID) error
- func (s *Store) DeleteProject(ctx context.Context, projectID workspace.ProjectID) error
- func (s *Store) DeleteUnitType(ctx context.Context, unitType workspace.UnitTypeID) error
- func (s *Store) EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Environment, error)
- func (s *Store) Environments(ctx context.Context, project workspace.ProjectID) ([]workspace.Environment, error)
- func (s *Store) LockProject(ctx context.Context, projectID workspace.ProjectID) (workspace.Project, error)
- func (s *Store) NextSortOrder(ctx context.Context, project workspace.ProjectID) (int, error)
- func (s *Store) ProjectByKey(ctx context.Context, key string) (workspace.Project, error)
- func (s *Store) Projects(ctx context.Context, all bool, ids []workspace.ProjectID) ([]workspace.Project, error)
- func (s *Store) PurgeDeletedProjects(ctx context.Context, limit int) (int, error)
- func (s *Store) TryLockProjectPurge(ctx context.Context) (bool, error)
- func (s *Store) UnitTypeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.UnitType, error)
- func (s *Store) UnitTypes(ctx context.Context, project workspace.ProjectID) ([]workspace.UnitType, error)
- func (s *Store) UpdateAttribute(ctx context.Context, a workspace.Attribute) error
- func (s *Store) UpdateEnvironment(ctx context.Context, e workspace.Environment) error
- func (s *Store) UpdateProject(ctx context.Context, p workspace.Project) error
- func (s *Store) UpdateUnitType(ctx context.Context, u workspace.UnitType) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectPurgeTables ¶ added in v0.2.0
func ProjectPurgeTables() []string
ProjectPurgeTables returns the tables the project purge deletes a deleted project's rows from.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the repository of projects and what they declare.
func (*Store) AttributeByKey ¶
func (s *Store) AttributeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Attribute, error)
AttributeByKey returns project's attribute with key, locking its row when lock is set, or appworkspace.ErrNotFound.
func (*Store) Attributes ¶
func (s *Store) Attributes(ctx context.Context, project workspace.ProjectID) ([]workspace.Attribute, error)
Attributes returns the attributes of project by key.
func (*Store) CountEnvironments ¶
CountEnvironments returns how many environments project has.
func (*Store) CreateAttribute ¶
CreateAttribute stores a.
func (*Store) CreateEnvironment ¶
CreateEnvironment stores e.
func (*Store) CreateProject ¶
CreateProject stores p.
func (*Store) CreateUnitType ¶
CreateUnitType stores u.
func (*Store) DeclarationKeyTaken ¶
func (s *Store) DeclarationKeyTaken(ctx context.Context, project workspace.ProjectID, key string) (bool, error)
DeclarationKeyTaken reports whether a unit type or an attribute of project has key.
func (*Store) DeleteAttribute ¶
DeleteAttribute deletes the attribute.
func (*Store) DeleteEnvironment ¶
DeleteEnvironment deletes the environment.
func (*Store) DeleteProject ¶ added in v0.2.0
DeleteProject deletes the project's row; every table holding rows of the project references it with ON DELETE CASCADE, or is cleared by the project purge afterwards.
func (*Store) DeleteUnitType ¶
DeleteUnitType deletes the unit type.
func (*Store) EnvironmentByKey ¶
func (s *Store) EnvironmentByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.Environment, error)
EnvironmentByKey returns project's environment with key, locking its row when lock is set, or appworkspace.ErrNotFound.
func (*Store) Environments ¶
func (s *Store) Environments(ctx context.Context, project workspace.ProjectID) ([]workspace.Environment, error)
Environments returns the environments of project by sort order.
func (*Store) LockProject ¶
func (s *Store) LockProject(ctx context.Context, projectID workspace.ProjectID) (workspace.Project, error)
LockProject returns the project with projectID, locking its row until the unit of work ends, so changes to the project and to what it holds are made one at a time.
func (*Store) NextSortOrder ¶
NextSortOrder returns the sort order that places a new environment of project after its others.
func (*Store) ProjectByKey ¶
ProjectByKey returns the project with key, or appworkspace.ErrNotFound.
func (*Store) Projects ¶
func (s *Store) Projects(ctx context.Context, all bool, ids []workspace.ProjectID) ([]workspace.Project, error)
Projects returns every project when all is set, else those of ids, ordered by key.
func (*Store) PurgeDeletedProjects ¶ added in v0.2.0
PurgeDeletedProjects deletes at most limit rows, table after table, of projects that no longer exist. A table's projects are walked from its index one at a time rather than by scanning its rows, so a table of millions of rows of a few live projects costs a few probes.
func (*Store) TryLockProjectPurge ¶ added in v0.2.0
TryLockProjectPurge takes the purge lock until the transaction ends, without waiting; false when another replica holds it. The key names the schema too, so instances sharing a database in separate schemas purge independently.
func (*Store) UnitTypeByKey ¶
func (s *Store) UnitTypeByKey(ctx context.Context, project workspace.ProjectID, key string, lock bool) (workspace.UnitType, error)
UnitTypeByKey returns project's unit type with key, locking its row when lock is set, or appworkspace.ErrNotFound.
func (*Store) UnitTypes ¶
func (s *Store) UnitTypes(ctx context.Context, project workspace.ProjectID) ([]workspace.UnitType, error)
UnitTypes returns the unit types of project by key.
func (*Store) UpdateAttribute ¶
UpdateAttribute stores a's name, description and version.
func (*Store) UpdateEnvironment ¶
UpdateEnvironment stores e's name, protection and version.
func (*Store) UpdateProject ¶
UpdateProject stores p's name, description and version.