workspace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package workspace is the PostgreSQL repository of the workspace context: projects, their environments, unit types and attributes.

Index

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 NewStore

func NewStore(pool *pgxpool.Pool) *Store

NewStore returns the repository on pool.

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

func (s *Store) CountEnvironments(ctx context.Context, project workspace.ProjectID) (int, error)

CountEnvironments returns how many environments project has.

func (*Store) CreateAttribute

func (s *Store) CreateAttribute(ctx context.Context, a workspace.Attribute) error

CreateAttribute stores a.

func (*Store) CreateEnvironment

func (s *Store) CreateEnvironment(ctx context.Context, e workspace.Environment) error

CreateEnvironment stores e.

func (*Store) CreateProject

func (s *Store) CreateProject(ctx context.Context, p workspace.Project) error

CreateProject stores p.

func (*Store) CreateUnitType

func (s *Store) CreateUnitType(ctx context.Context, u workspace.UnitType) error

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

func (s *Store) DeleteAttribute(ctx context.Context, attribute workspace.AttributeID) error

DeleteAttribute deletes the attribute.

func (*Store) DeleteEnvironment

func (s *Store) DeleteEnvironment(ctx context.Context, environment workspace.EnvironmentID) error

DeleteEnvironment deletes the environment.

func (*Store) DeleteProject added in v0.2.0

func (s *Store) DeleteProject(ctx context.Context, projectID workspace.ProjectID) error

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

func (s *Store) DeleteUnitType(ctx context.Context, unitType workspace.UnitTypeID) error

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

func (s *Store) NextSortOrder(ctx context.Context, project workspace.ProjectID) (int, error)

NextSortOrder returns the sort order that places a new environment of project after its others.

func (*Store) ProjectByKey

func (s *Store) ProjectByKey(ctx context.Context, key string) (workspace.Project, error)

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

func (s *Store) PurgeDeletedProjects(ctx context.Context, limit int) (int, error)

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

func (s *Store) TryLockProjectPurge(ctx context.Context) (bool, error)

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

func (s *Store) UpdateAttribute(ctx context.Context, a workspace.Attribute) error

UpdateAttribute stores a's name, description and version.

func (*Store) UpdateEnvironment

func (s *Store) UpdateEnvironment(ctx context.Context, e workspace.Environment) error

UpdateEnvironment stores e's name, protection and version.

func (*Store) UpdateProject

func (s *Store) UpdateProject(ctx context.Context, p workspace.Project) error

UpdateProject stores p's name, description and version.

func (*Store) UpdateUnitType

func (s *Store) UpdateUnitType(ctx context.Context, u workspace.UnitType) error

UpdateUnitType stores u's name, description and version.

Jump to

Keyboard shortcuts

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