deployments

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package deployments manages deployment event records for services.

Index

Constants

View Source
const (
	StatusPending   = "pending"
	StatusDeploying = "deploying"
	StatusRunning   = "running"
	StatusFailed    = "failed"
	StatusCrashed   = "crashed"
	StatusStopped   = "stopped"
	StatusCancelled = "cancelled"
)

Status constants for deployment lifecycle.

View Source
const (
	TriggerManual       = "manual"
	TriggerBuild        = "build"
	TriggerRestart      = "restart"
	TriggerReconciler   = "reconciler"
	TriggerAutoRecovery = "auto_recovery"
)

Trigger constants for deployment attribution.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deployment

type Deployment struct {
	ID           string `json:"id"`
	ServiceID    string `json:"service_id"`
	TenantID     string `json:"tenant_id"`
	BuildID      string `json:"build_id,omitempty"`
	Image        string `json:"image"`
	Status       string `json:"status"`
	Trigger      string `json:"trigger"`
	ContainerID  string `json:"container_id,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`
	StartedAt    int64  `json:"started_at"`
	CompletedAt  *int64 `json:"completed_at,omitempty"`
	CancelledAt  *int64 `json:"cancelled_at,omitempty"`
	CreatedAt    int64  `json:"created_at"`
}

Deployment represents a single deployment event for a service.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store handles deployment record persistence.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore creates a deployment store.

func (*Store) Cancel

func (s *Store) Cancel(ctx context.Context, tenantID, deploymentID string) (*Deployment, error)

Cancel transitions a deployment to cancelled status. Only "pending" deployments (before any work starts) can be cancelled. Returns a Conflict error otherwise, including for "deploying", where the work cannot be stopped.

func (*Store) Create

func (s *Store) Create(ctx context.Context, d *Deployment) error

Create inserts a new deployment record.

func (*Store) Get

func (s *Store) Get(ctx context.Context, tenantID, deploymentID string) (*Deployment, error)

Get retrieves a single deployment by ID, scoped to tenant.

func (*Store) LatestForService

func (s *Store) LatestForService(ctx context.Context, serviceID string) (*Deployment, error)

LatestForService returns the most recent deployment for a service.

func (*Store) ListByService

func (s *Store) ListByService(ctx context.Context, tenantID, serviceID string, limit, offset int) ([]*Deployment, error)

ListByService returns paginated deployments for a service, newest first.

func (*Store) ListByTenant

func (s *Store) ListByTenant(ctx context.Context, tenantID string, limit, offset int) ([]*Deployment, error)

ListByTenant returns paginated deployments across all services for a tenant, newest first.

func (*Store) UpdateStatus

func (s *Store) UpdateStatus(ctx context.Context, deploymentID, status string, opts ...UpdateOption) error

UpdateStatus transitions a deployment to a new status, optionally setting container_id, error_message, and completed_at.

type UpdateOption

type UpdateOption func(*updateOpts)

UpdateOption configures optional fields on UpdateStatus.

func WithCompletedAt

func WithCompletedAt(ts int64) UpdateOption

WithCompletedAt sets the completed_at timestamp on status update.

func WithContainerID

func WithContainerID(cid string) UpdateOption

WithContainerID sets the container_id on status update.

func WithError

func WithError(msg string) UpdateOption

WithError sets the error_message on status update.

Jump to

Keyboard shortcuts

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