deploy

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlueGreenState

type BlueGreenState struct {
	ActiveEnv  Environment `json:"active_env"`
	StandbyEnv Environment `json:"standby_env"`
	ActiveVer  int         `json:"active_version"`
	StandbyVer int         `json:"standby_version"`
}

BlueGreenState tracks the current blue-green deployment state.

type BlueGreenStrategy

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

BlueGreenStrategy implements zero-downtime deployments by swapping between two environments.

func NewBlueGreenStrategy

func NewBlueGreenStrategy(logger *slog.Logger) *BlueGreenStrategy

NewBlueGreenStrategy creates a new BlueGreenStrategy.

func (*BlueGreenStrategy) Execute

Execute performs a blue-green deployment: deploy to standby, health check, then switch traffic.

func (*BlueGreenStrategy) GetState

func (s *BlueGreenStrategy) GetState(workflowID string) (*BlueGreenState, bool)

GetState returns the current blue-green state for a workflow.

func (*BlueGreenStrategy) Name

func (s *BlueGreenStrategy) Name() string

Name returns the strategy identifier.

func (*BlueGreenStrategy) Rollback

func (s *BlueGreenStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)

Rollback switches traffic back to the previous environment.

func (*BlueGreenStrategy) Validate

func (s *BlueGreenStrategy) Validate(config map[string]any) error

Validate checks the blue-green configuration.

type CanaryConfig

type CanaryConfig struct {
	InitialPercent float64       `json:"initial_percent"` // default 10
	Increment      float64       `json:"increment"`       // default 20
	Interval       time.Duration `json:"interval"`        // default 30s
	ErrorThreshold float64       `json:"error_threshold"` // default 5 (percent)
}

CanaryConfig holds the tunable parameters for canary deployments.

func DefaultCanaryConfig

func DefaultCanaryConfig() CanaryConfig

DefaultCanaryConfig returns the default canary configuration.

type CanaryStrategy

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

CanaryStrategy implements gradual traffic-shifting deployments.

func NewCanaryStrategy

func NewCanaryStrategy(logger *slog.Logger) *CanaryStrategy

NewCanaryStrategy creates a new CanaryStrategy.

func (*CanaryStrategy) Execute

Execute performs a canary deployment with gradual traffic shifting.

func (*CanaryStrategy) GetSplit

func (s *CanaryStrategy) GetSplit(workflowID string) (*TrafficSplit, bool)

GetSplit returns the current traffic split for a workflow.

func (*CanaryStrategy) Name

func (s *CanaryStrategy) Name() string

Name returns the strategy identifier.

func (*CanaryStrategy) Rollback

func (s *CanaryStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)

Rollback immediately shifts all traffic back to the stable version.

func (*CanaryStrategy) SetHealthCheck

func (s *CanaryStrategy) SetHealthCheck(fn func(ctx context.Context, workflowID string, version int) (float64, error))

SetHealthCheck sets a custom health check function for canary evaluation.

func (*CanaryStrategy) Validate

func (s *CanaryStrategy) Validate(config map[string]any) error

Validate checks the canary-specific configuration.

type DeploymentPlan

type DeploymentPlan struct {
	WorkflowID  string         `json:"workflow_id"`
	FromVersion int            `json:"from_version"`
	ToVersion   int            `json:"to_version"`
	Strategy    string         `json:"strategy"` // "rolling", "blue-green", "canary"
	Config      map[string]any `json:"config"`
}

DeploymentPlan describes a deployment to execute.

type DeploymentResult

type DeploymentResult struct {
	Status      string    `json:"status"` // "success", "failed", "rolled_back"
	StartedAt   time.Time `json:"started_at"`
	CompletedAt time.Time `json:"completed_at"`
	Message     string    `json:"message"`
	RolledBack  bool      `json:"rolled_back"`
}

DeploymentResult captures the outcome of a deployment.

type DeploymentStrategy

type DeploymentStrategy interface {
	// Name returns the strategy identifier (e.g., "rolling", "blue-green", "canary").
	Name() string

	// Validate checks the strategy-specific configuration.
	Validate(config map[string]any) error

	// Execute runs the deployment according to the plan.
	Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
}

DeploymentStrategy defines the interface for workflow deployment strategies.

type Environment

type Environment string

Environment identifies a blue-green deployment slot.

const (
	EnvBlue  Environment = "blue"
	EnvGreen Environment = "green"
)

type Executor

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

Executor bridges deployment strategies with cloud providers. It looks up the appropriate strategy and provider, validates the plan, and delegates execution to the cloud provider.

func NewExecutor

func NewExecutor(strategies *StrategyRegistry) *Executor

NewExecutor creates an Executor backed by the given strategy registry.

func (*Executor) Deploy

func (e *Executor) Deploy(ctx context.Context, providerName string, req provider.DeployRequest) (*provider.DeployResult, error)

Deploy executes a deployment through the named provider, using the strategy identified in the request. It validates the strategy config, deploys via the provider, and handles rollback on failure when configured.

func (*Executor) GetProvider

func (e *Executor) GetProvider(name string) (provider.CloudProvider, bool)

GetProvider returns the cloud provider with the given name, or false if not found.

func (*Executor) RegisterProvider

func (e *Executor) RegisterProvider(name string, p provider.CloudProvider)

RegisterProvider adds a cloud provider under the given name.

type RollingConfig

type RollingConfig struct {
	BatchSize int           `json:"batch_size"` // default 1
	Delay     time.Duration `json:"delay"`      // default 5s
}

RollingConfig holds the tunable parameters for rolling deployments.

func DefaultRollingConfig

func DefaultRollingConfig() RollingConfig

DefaultRollingConfig returns the default rolling configuration.

type RollingStrategy

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

RollingStrategy implements simple rolling update deployments, updating instances one batch at a time.

func NewRollingStrategy

func NewRollingStrategy(logger *slog.Logger) *RollingStrategy

NewRollingStrategy creates a new RollingStrategy.

func (*RollingStrategy) Execute

Execute performs a rolling deployment, processing instances in batches.

func (*RollingStrategy) Name

func (s *RollingStrategy) Name() string

Name returns the strategy identifier.

func (*RollingStrategy) Validate

func (s *RollingStrategy) Validate(config map[string]any) error

Validate checks the rolling-specific configuration.

type StrategyRegistry

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

StrategyRegistry holds the available deployment strategies.

func NewStrategyRegistry

func NewStrategyRegistry(logger *slog.Logger) *StrategyRegistry

NewStrategyRegistry creates a registry pre-loaded with built-in strategies.

func (*StrategyRegistry) Execute

func (r *StrategyRegistry) Execute(plan *DeploymentPlan) (*DeploymentResult, error)

Execute is a convenience method that looks up a strategy and executes a plan.

func (*StrategyRegistry) Get

Get returns the strategy with the given name, or false if not found.

func (*StrategyRegistry) List

func (r *StrategyRegistry) List() []string

List returns the sorted names of all registered strategies.

func (*StrategyRegistry) Register

func (r *StrategyRegistry) Register(s DeploymentStrategy)

Register adds a strategy to the registry, replacing any existing one with the same name.

type TrafficSplit

type TrafficSplit struct {
	CanaryPercent float64 `json:"canary_percent"`
	StablePercent float64 `json:"stable_percent"`
	CanaryVersion int     `json:"canary_version"`
	StableVersion int     `json:"stable_version"`
}

TrafficSplit tracks how traffic is distributed between versions.

Jump to

Keyboard shortcuts

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