computeaccess

package
v0.0.7-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComputeAccess

type ComputeAccess struct {
	Entitlement *ComputeEntitlement
	Lease       *SharedComputeLease
}

ComputeAccess groups an entitlement and its shared-capacity lease. It is not persisted as its own record.

type ComputeAccessActivation

type ComputeAccessActivation struct {
	OrganisationID    string
	EntitlementSource ComputeEntitlementSource
	StartsAt          time.Time
	ExpiresAt         *time.Time
}

ComputeAccessActivation describes the entitlement an organisation receives. Platform capacity is store configuration, not activation input.

type ComputeEntitlement

type ComputeEntitlement struct {
	ID             string                   `gorm:"primary_key;default:gen_random_uuid()" json:"id"`
	OrganisationID string                   `gorm:"not null;uniqueIndex:idx_compute_entitlement_org_source" json:"organisation_id"`
	Source         ComputeEntitlementSource `gorm:"not null;uniqueIndex:idx_compute_entitlement_org_source" json:"source"`
	Status         ComputeEntitlementStatus `gorm:"not null" json:"status"`
	StartsAt       time.Time                `gorm:"not null" json:"starts_at"`
	ExpiresAt      *time.Time               `gorm:"index" json:"expires_at,omitempty"`
	CreatedAt      time.Time                `json:"created_at"`
	UpdatedAt      time.Time                `json:"updated_at"`
}

ComputeEntitlement records why an organisation may use compute.

type ComputeEntitlementSource

type ComputeEntitlementSource string
const ComputeEntitlementSourceTrial ComputeEntitlementSource = "trial"

type ComputeEntitlementStatus

type ComputeEntitlementStatus string
const ComputeEntitlementStatusActive ComputeEntitlementStatus = "active"

type Service

type Service interface {
	Activate(ctx context.Context, organisationID string) (*ComputeAccess, *errors.ServiceError)
}

Service manages the entitlement and shared-compute lease that back an organisation's use of managed compute. Activate creates the entitlement and shared-compute lease for an organisation on first use. If they already exist, it returns the existing compute access. Policy calls it to ensure access is granted before any compute is used.

func NewService

func NewService(spec ServiceSpec) Service

NewService configures the default entitlement issued when managed compute is activated for the first time.

type ServiceSpec

type ServiceSpec struct {
	Store                      Store
	DefaultEntitlementSource   ComputeEntitlementSource
	DefaultEntitlementDuration time.Duration
	Now                        func() time.Time
}

type SharedComputeLease

type SharedComputeLease struct {
	ID               string                  `gorm:"primary_key;default:gen_random_uuid()" json:"id"`
	OrganisationID   string                  `gorm:"not null;index" json:"organisation_id"`
	EntitlementID    string                  `gorm:"not null;uniqueIndex" json:"entitlement_id"`
	State            SharedComputeLeaseState `gorm:"not null" json:"state"`
	ActivatedAt      time.Time               `gorm:"not null" json:"activated_at"`
	CleanupStartedAt *time.Time              `json:"cleanup_started_at,omitempty"`
	CleanedUpAt      *time.Time              `json:"cleaned_up_at,omitempty"`
	ErrorAt          *time.Time              `json:"error_at,omitempty"`
	ErrorMessage     string                  `json:"error_message,omitempty"`
	CreatedAt        time.Time               `json:"created_at"`
	UpdatedAt        time.Time               `json:"updated_at"`
}

SharedComputeLease records platform capacity reserved for an organisation. Capacity remains reserved until runtime cleanup reaches the cleaned state.

type SharedComputeLeaseState

type SharedComputeLeaseState string
const (
	SharedComputeLeaseStateActive         SharedComputeLeaseState = "active"
	SharedComputeLeaseStateCleanupPending SharedComputeLeaseState = "cleanup_pending"
	SharedComputeLeaseStateCleaning       SharedComputeLeaseState = "cleaning"
	SharedComputeLeaseStateCleaned        SharedComputeLeaseState = "cleaned"
	SharedComputeLeaseStateError          SharedComputeLeaseState = "error"
)

type Store

type Store interface {
	Activate(ctx context.Context, activation ComputeAccessActivation) (*ComputeAccess, *errors.ServiceError)
}

Store atomically persists an entitlement and its shared-compute lease with the capacity-consuming resource that first activates them.

Jump to

Keyboard shortcuts

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