{"modulePath":"github.com/Stackdome/stackdome","version":"v0.0.7-alpha","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package computeaccess\n\n## Types\n\n```go\ntype ComputeAccess struct {\n\tEntitlement *ComputeEntitlement\n\tLease       *SharedComputeLease\n}\n```\nComputeAccess groups an entitlement and its shared-capacity lease. It is not persisted as its own record.\n\n```go\ntype ComputeAccessActivation struct {\n\tOrganisationID    string\n\tEntitlementSource ComputeEntitlementSource\n\tStartsAt          time.Time\n\tExpiresAt         *time.Time\n}\n```\nComputeAccessActivation describes the entitlement an organisation receives. Platform capacity is store configuration, not activation input.\n\n```go\ntype ComputeEntitlement struct {\n\tID             string                   `gorm:\"primary_key;default:gen_random_uuid()\" json:\"id\"`\n\tOrganisationID string                   `gorm:\"not null;uniqueIndex:idx_compute_entitlement_org_source\" json:\"organisation_id\"`\n\tSource         ComputeEntitlementSource `gorm:\"not null;uniqueIndex:idx_compute_entitlement_org_source\" json:\"source\"`\n\tStatus         ComputeEntitlementStatus `gorm:\"not null\" json:\"status\"`\n\tStartsAt       time.Time                `gorm:\"not null\" json:\"starts_at\"`\n\tExpiresAt      *time.Time               `gorm:\"index\" json:\"expires_at,omitempty\"`\n\tCreatedAt      time.Time                `json:\"created_at\"`\n\tUpdatedAt      time.Time                `json:\"updated_at\"`\n}\n```\nComputeEntitlement records why an organisation may use compute.\n\n```go\ntype ComputeEntitlementSource string\n```\n\n```go\nconst ComputeEntitlementSourceTrial ComputeEntitlementSource = \"trial\"\n```\n\n```go\ntype ComputeEntitlementStatus string\n```\n\n```go\nconst ComputeEntitlementStatusActive ComputeEntitlementStatus = \"active\"\n```\n\n```go\ntype Service interface {\n\tActivate(ctx context.Context, organisationID string) (*ComputeAccess, *errors.ServiceError)\n}\n```\nService 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.\n\n```go\nfunc NewService(spec ServiceSpec) Service\n```\nNewService configures the default entitlement issued when managed compute is activated for the first time.\n\n```go\ntype ServiceSpec struct {\n\tStore                      Store\n\tDefaultEntitlementSource   ComputeEntitlementSource\n\tDefaultEntitlementDuration time.Duration\n\tNow                        func() time.Time\n}\n```\n\n```go\ntype SharedComputeLease struct {\n\tID               string                  `gorm:\"primary_key;default:gen_random_uuid()\" json:\"id\"`\n\tOrganisationID   string                  `gorm:\"not null;index\" json:\"organisation_id\"`\n\tEntitlementID    string                  `gorm:\"not null;uniqueIndex\" json:\"entitlement_id\"`\n\tState            SharedComputeLeaseState `gorm:\"not null\" json:\"state\"`\n\tActivatedAt      time.Time               `gorm:\"not null\" json:\"activated_at\"`\n\tCleanupStartedAt *time.Time              `json:\"cleanup_started_at,omitempty\"`\n\tCleanedUpAt      *time.Time              `json:\"cleaned_up_at,omitempty\"`\n\tErrorAt          *time.Time              `json:\"error_at,omitempty\"`\n\tErrorMessage     string                  `json:\"error_message,omitempty\"`\n\tCreatedAt        time.Time               `json:\"created_at\"`\n\tUpdatedAt        time.Time               `json:\"updated_at\"`\n}\n```\nSharedComputeLease records platform capacity reserved for an organisation. Capacity remains reserved until runtime cleanup reaches the cleaned state.\n\n```go\ntype SharedComputeLeaseState string\n```\n\n```go\nconst (\n\tSharedComputeLeaseStateActive         SharedComputeLeaseState = \"active\"\n\tSharedComputeLeaseStateCleanupPending SharedComputeLeaseState = \"cleanup_pending\"\n\tSharedComputeLeaseStateCleaning       SharedComputeLeaseState = \"cleaning\"\n\tSharedComputeLeaseStateCleaned        SharedComputeLeaseState = \"cleaned\"\n\tSharedComputeLeaseStateError          SharedComputeLeaseState = \"error\"\n)\n```\n\n```go\ntype Store interface {\n\tActivate(ctx context.Context, activation ComputeAccessActivation) (*ComputeAccess, *errors.ServiceError)\n}\n```\nStore atomically persists an entitlement and its shared-compute lease with the capacity-consuming resource that first activates them.\n\n","path":"github.com/Stackdome/stackdome/pkg/computeaccess","name":"computeaccess","synopsis":"","isRedistributable":true}
