Documentation
¶
Overview ¶
Package management holds the state changes the control-plane management interface applies. They live outside the handlers so they are reachable without gin: what these operations get wrong is never the HTTP.
Each one owns the cache evictions its own write invalidates, and reports failures as sentinel errors rather than database ones, so the routes above map outcomes to status codes without knowing what backs them.
Index ¶
- Constants
- Variables
- type JobInserter
- type Project
- type ProjectBanProjection
- type ProjectBlockProjection
- type ProjectLimitsProjection
- type ProjectMemberIdentity
- type ProjectMemberProjection
- type Service
- func (s *Service) ApplyProjectBan(ctx context.Context, jobs JobInserter, projection ProjectBanProjection) error
- func (s *Service) ApplyProjectBlock(ctx context.Context, projection ProjectBlockProjection) error
- func (s *Service) ApplyProjectLimits(ctx context.Context, projection ProjectLimitsProjection) error
- func (s *Service) ApplyProjectMember(ctx context.Context, projection ProjectMemberProjection) error
- func (s *Service) UpsertProject(ctx context.Context, project Project) (stored Project, created bool, err error)
Constants ¶
const ( ProjectMemberRoleOwner = "owner" ProjectMemberRoleMember = "member" ProjectMemberRoleViewer = "viewer" )
Variables ¶
var ( ErrInvalidProjectLimits = errors.New("invalid project limits") // A pair the columns will not hold, currently a free disk allowance above // the ceiling. The caller sent values this side will not store, which is its // error to fix. ErrProjectLimitsRejected = errors.New("project limits violate a constraint") )
var ( ErrProjectNotFound = errors.New("project not found") ErrInvalidProjectMember = errors.New("invalid project member") ErrDuplicateProjectIdentity = errors.New("duplicate project identity") ErrProjectIdentityOwnedByUser = errors.New("project identity is linked to another user") )
var ( // ErrProjectSlugTaken reports a slug already held on this cluster, possibly // by a project the caller has never heard of. ErrProjectSlugTaken = errors.New("project slug is already taken") // ErrProjectRaced reports an id inserted between the existence check and // this request's own insert. ErrProjectRaced = errors.New("project was created concurrently") )
var ErrInvalidProjectBan = errors.New("invalid project ban state")
var ErrInvalidProjectBlock = errors.New("invalid project block state")
Functions ¶
This section is empty.
Types ¶
type JobInserter ¶
type Project ¶
Project is the set of properties the caller synchronizes. It sends all of them on every push, so a reconcile is a complete statement rather than a patch.
Slug moves like the others, and the project's template aliases follow it in the same transaction: each one held under an earlier slug is also given under the new one. The old names stay, because rewriting them would break every reference a user has already scripted.
type ProjectBanProjection ¶
type ProjectBlockProjection ¶
type ProjectLimitsProjection ¶
type ProjectLimitsProjection struct {
ProjectID uuid.UUID
Revision int64
// Zero when the caller did not say.
DecidedAt time.Time
MaxLengthHours int64
ConcurrentSandboxes int64
ConcurrentTemplateBuilds int64
MaxVCPU int64
MaxRAMMB int64
DiskMB int64
EventsTTLDays int64
DefaultFreeDiskSizeMB int64
MaxFreeDiskSizeMB int64
APITeamRPSList int64
APITeamRPSDelete int64
MaxSecrets int64
}
The values arrive absolute: the caller owns plans and add-ons and has already resolved them, which is what lets the team lookups prefer this row over default_limits.
type ProjectMemberIdentity ¶
type ProjectMemberProjection ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Auth and project state use separately configured pools; transactions cannot span them.
func NewService ¶
func NewService(db *authdb.Client, projectDB *sqlcdb.Client, cache sharedauth.Service, meterProvider metric.MeterProvider) *Service
func (*Service) ApplyProjectBan ¶
func (s *Service) ApplyProjectBan(ctx context.Context, jobs JobInserter, projection ProjectBanProjection) error
func (*Service) ApplyProjectBlock ¶
func (s *Service) ApplyProjectBlock(ctx context.Context, projection ProjectBlockProjection) error
func (*Service) ApplyProjectLimits ¶
func (s *Service) ApplyProjectLimits(ctx context.Context, projection ProjectLimitsProjection) error
ApplyProjectLimits records a project's effective limits, behind the revision that decides whether this delivery is the newest one.
The eviction runs whether or not the delivery wrote. An accepted write whose eviction did not finish -- the process died, or one key of several failed -- is retried by a caller carrying the same revision, which this side drops; skipping it there would leave the cache serving the old limits until the entry expires, with the retry that was meant to repair it reporting success.
func (*Service) ApplyProjectMember ¶
func (s *Service) ApplyProjectMember(ctx context.Context, projection ProjectMemberProjection) error
func (*Service) UpsertProject ¶
func (s *Service) UpsertProject(ctx context.Context, project Project) (stored Project, created bool, err error)
UpsertProject creates a project or reconciles an existing one, reporting which happened.
One operation serves both because the caller cannot tell them apart: it retries, and a retry after a response it never saw has to land on the same state as the original.