Documentation
¶
Index ¶
- type BlueGreenState
- type BlueGreenStrategy
- func (s *BlueGreenStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
- func (s *BlueGreenStrategy) GetState(workflowID string) (*BlueGreenState, bool)
- func (s *BlueGreenStrategy) Name() string
- func (s *BlueGreenStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
- func (s *BlueGreenStrategy) Validate(config map[string]any) error
- type CanaryConfig
- type CanaryStrategy
- func (s *CanaryStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
- func (s *CanaryStrategy) GetSplit(workflowID string) (*TrafficSplit, bool)
- func (s *CanaryStrategy) Name() string
- func (s *CanaryStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
- func (s *CanaryStrategy) SetHealthCheck(fn func(ctx context.Context, workflowID string, version int) (float64, error))
- func (s *CanaryStrategy) Validate(config map[string]any) error
- type DeploymentPlan
- type DeploymentResult
- type DeploymentStrategy
- type Environment
- type Executor
- type RollingConfig
- type RollingStrategy
- type StrategyRegistry
- type TrafficSplit
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 ¶
func (s *BlueGreenStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
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.
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 ¶
func (s *CanaryStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
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.
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 ¶
func (s *RollingStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
Execute performs a rolling deployment, processing instances in batches.
func (*RollingStrategy) Name ¶
func (s *RollingStrategy) Name() string
Name returns the strategy identifier.
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 ¶
func (r *StrategyRegistry) Get(name string) (DeploymentStrategy, bool)
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.