Documentation
¶
Overview ¶
Package lifecycle computes durable desired-state reconciliation actions.
Index ¶
- Variables
- func IdleSince(view View) time.Time
- func ValidTerminationReason(reason string) bool
- type Action
- type ActiveSessionCanceller
- type AssignmentScheduler
- type BatchReconcileStore
- type Decision
- type EffectBrokerConfig
- type EffectExecutor
- type FileAssetCatalog
- type PostgresEffectBroker
- type ReconcileStore
- type Reconciler
- type SignedAsset
- type SignedAssetCatalog
- type SnapshotRetentionStore
- type SnapshotRetentionWorker
- type View
Constants ¶
This section is empty.
Variables ¶
var LoadFileAssetCatalog = assetcatalog.LoadFileAssetCatalog
Functions ¶
func IdleSince ¶ added in v0.3.1
IdleSince is the instant the running Instance's idle window is measured from, and the single reference both the drain decision and the wake-up it schedules use. Useful activity is generation-scoped, but the Sandbox carries one denormalized `last_activity_at` across generations, so a restarted Sandbox reports activity that belongs to the Instance before it. An Instance cannot have been idle for longer than it has been ready, so readiness bounds the window and a restart earns its full idle timeout instead of draining on its first reconciliation.
func ValidTerminationReason ¶
ValidTerminationReason recognizes the complete stable v1 reason vocabulary.
Types ¶
type ActiveSessionCanceller ¶
type ActiveSessionCanceller interface {
CancelSandboxSessions(context.Context, string, int64, string, time.Time) (int64, error)
}
ActiveSessionCanceller sends fenced cancellation to in-flight generation operations.
type AssignmentScheduler ¶
type AssignmentScheduler interface {
Schedule(context.Context, scheduler.ScheduleRequest) (scheduler.DurableAssignment, bool, error)
}
AssignmentScheduler persists one fenced placement and runner command atomically.
type BatchReconcileStore ¶
type BatchReconcileStore interface {
ClaimLifecycleBatch(ctx context.Context, workerID string, now time.Time, claimDuration time.Duration, batchSize int, wakeTrigger ports.LifecycleWakeTrigger) ([]ports.LifecycleReconcileClaim, error)
}
BatchReconcileStore claims an ordered cohort under the same worker fence.
type Decision ¶
Decision is the single next action and any stable termination reason it establishes.
type EffectBrokerConfig ¶
type EffectBrokerConfig struct {
AssignmentClaimDuration time.Duration
AssignmentDeadline time.Duration
HeartbeatTimeout time.Duration
RetryLimit int64
SerializationRetryLimit int
AssetCatalog SignedAssetCatalog
SessionCanceller ActiveSessionCanceller
NewID func(string) string
NewFencingToken func() ([]byte, error)
Now func() time.Time
}
EffectBrokerConfig contains explicit lifecycle effect bounds and artifact trust.
type EffectExecutor ¶
type EffectExecutor interface {
ExecuteLifecycleEffect(
ctx context.Context,
claim ports.LifecycleReconcileClaim,
decision Decision,
now time.Time,
nextReconcileAt time.Time,
) error
}
EffectExecutor performs one durable Runner effect.
type FileAssetCatalog ¶
type FileAssetCatalog = assetcatalog.FileAssetCatalog
type PostgresEffectBroker ¶
type PostgresEffectBroker struct {
// contains filtered or unexported fields
}
PostgresEffectBroker turns lifecycle decisions into durable scheduler and runner commands.
func NewPostgresEffectBroker ¶
func NewPostgresEffectBroker( ctx context.Context, databaseURL string, assignmentScheduler AssignmentScheduler, config EffectBrokerConfig, ) (*PostgresEffectBroker, error)
NewPostgresEffectBroker validates the durable effect composition.
func (*PostgresEffectBroker) Close ¶
func (broker *PostgresEffectBroker) Close()
func (*PostgresEffectBroker) ExecuteLifecycleEffect ¶
func (broker *PostgresEffectBroker) ExecuteLifecycleEffect( ctx context.Context, claim ports.LifecycleReconcileClaim, decision Decision, now time.Time, nextReconcileAt time.Time, ) error
ExecuteLifecycleEffect executes one restart-safe external-effect transition.
type ReconcileStore ¶
type ReconcileStore interface {
ClaimLifecycle(ctx context.Context, workerID string, now time.Time, claimDuration time.Duration, wakeTrigger ports.LifecycleWakeTrigger) (ports.LifecycleReconcileClaim, bool, error)
ApplyLifecycleAction(ctx context.Context, claim ports.LifecycleReconcileClaim, action, terminationReason string, now, nextReconcileAt time.Time) error
}
ReconcileStore owns durable claims and compare-and-swap transition commits. The wake trigger is attribution evidence carried into the claim transaction; it never changes which work the claim query finds.
A zero nextReconcileAt is the parked schedule: the commit carries no durable deadline at all, so the Sandbox leaves the reconciliation work set until an external event schedules it again.
type Reconciler ¶
type Reconciler struct {
Store ReconcileStore
Effects EffectExecutor
WorkerID string
ClaimDuration time.Duration
PollInterval time.Duration
BatchSize int
}
Reconciler consumes durable desired state one idempotent transition at a time.
type SignedAsset ¶
type SignedAsset = assetcatalog.SignedAsset
type SignedAssetCatalog ¶
type SignedAssetCatalog = assetcatalog.SignedAssetCatalog
type SnapshotRetentionStore ¶
type SnapshotRetentionStore interface {
QueueExpiredSnapshotDelete(
context.Context,
ports.SnapshotRetentionInput,
) (bool, error)
}
SnapshotRetentionStore admits due local Snapshot deletions without involving object storage or retained-byte accounting.
type SnapshotRetentionWorker ¶
type SnapshotRetentionWorker struct {
Store SnapshotRetentionStore
PollInterval time.Duration
NewID func(string) string
NewFencingToken func() ([]byte, error)
}
SnapshotRetentionWorker queues at most one expired local Snapshot deletion.
type View ¶
type View struct {
Observed string
Desired string
StopEffectState string
GuestLiveness string
InstanceTerminationReason string
IntentTerminationReason string
HasInstance bool
ActiveSessions int64
ReadyAt time.Time
LastUsefulActivityAt time.Time
DrainStartedAt time.Time
DrainGrace time.Duration
IdleTimeout time.Duration
MaximumDuration time.Duration
}
View contains only durable inputs needed for one idempotent decision.