Documentation
¶
Overview ¶
Package deployments manages deployment event records for services.
Index ¶
- Constants
- type Deployment
- type Store
- func (s *Store) Cancel(ctx context.Context, tenantID, deploymentID string) (*Deployment, error)
- func (s *Store) Create(ctx context.Context, d *Deployment) error
- func (s *Store) Get(ctx context.Context, tenantID, deploymentID string) (*Deployment, error)
- func (s *Store) LatestForService(ctx context.Context, serviceID string) (*Deployment, error)
- func (s *Store) ListByService(ctx context.Context, tenantID, serviceID string, limit, offset int) ([]*Deployment, error)
- func (s *Store) ListByTenant(ctx context.Context, tenantID string, limit, offset int) ([]*Deployment, error)
- func (s *Store) UpdateStatus(ctx context.Context, deploymentID, status string, opts ...UpdateOption) error
- type UpdateOption
Constants ¶
const ( StatusPending = "pending" StatusDeploying = "deploying" StatusRunning = "running" StatusFailed = "failed" StatusCrashed = "crashed" StatusStopped = "stopped" StatusCancelled = "cancelled" )
Status constants for deployment lifecycle.
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 (*Store) Cancel ¶
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) LatestForService ¶
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.