Documentation
¶
Index ¶
- type CreateInstanceCall
- type DeleteInstanceCall
- type ExecCall
- type FakeHealthController
- func (f *FakeHealthController) AddInstance(service *types.Service, instance *types.Instance) error
- func (f *FakeHealthController) AddedInstances() []struct{ ... }
- func (f *FakeHealthController) GetHealthStatus(ctx context.Context, instanceID string) (*types.InstanceHealthStatus, error)
- func (f *FakeHealthController) RemoveInstance(instanceID string) error
- func (f *FakeHealthController) RemovedInstanceIDs() []string
- func (f *FakeHealthController) Start(ctx context.Context) error
- func (f *FakeHealthController) Stop() error
- type FakeInstanceController
- func (c *FakeInstanceController) AddInstance(instance *types.Instance)
- func (c *FakeInstanceController) CreateInstance(ctx context.Context, service *types.Service, instanceName string) (*types.Instance, error)
- func (c *FakeInstanceController) DeleteInstance(ctx context.Context, instance *types.Instance) error
- func (c *FakeInstanceController) Exec(ctx context.Context, instance *types.Instance, options types.ExecOptions) (types.ExecStream, error)
- func (c *FakeInstanceController) GetInstance(ctx context.Context, namespace, instanceID string) (*types.Instance, error)
- func (c *FakeInstanceController) GetInstanceByID(ctx context.Context, namespace, instanceID string) (*types.Instance, error)
- func (c *FakeInstanceController) GetInstanceLogs(ctx context.Context, instance *types.Instance, opts types.LogOptions) (io.ReadCloser, error)
- func (c *FakeInstanceController) GetInstanceStatus(ctx context.Context, instance *types.Instance) (*types.InstanceStatusInfo, error)
- func (c *FakeInstanceController) ListInstances(ctx context.Context, namespace string) ([]*types.Instance, error)
- func (c *FakeInstanceController) ListRunningInstances(ctx context.Context, namespace string) ([]*types.Instance, error)
- func (c *FakeInstanceController) RecreateInstance(ctx context.Context, service *types.Service, instance *types.Instance) (*types.Instance, error)
- func (c *FakeInstanceController) Reset()
- func (c *FakeInstanceController) RestartInstance(ctx context.Context, instance *types.Instance, reason InstanceRestartReason) error
- func (c *FakeInstanceController) StopInstance(ctx context.Context, instance *types.Instance) error
- func (c *FakeInstanceController) UpdateInstance(ctx context.Context, service *types.Service, instance *types.Instance) error
- type FakeScalingController
- func (f *FakeScalingController) CompleteOperation(namespace, serviceName string)
- func (f *FakeScalingController) CreateScalingOperation(ctx context.Context, service *types.Service, ...) error
- func (f *FakeScalingController) CreatedOperations() []*types.ScalingOperation
- func (f *FakeScalingController) GetActiveOperation(ctx context.Context, namespace, serviceName string) (*types.ScalingOperation, error)
- func (f *FakeScalingController) Start(ctx context.Context) error
- func (f *FakeScalingController) Stop()
- type HealthController
- type InstanceController
- type InstanceRestartReason
- type RecreateInstanceCall
- type RestartInstanceCall
- type RunningInstance
- type ScalingController
- type ServiceController
- type ServiceInstanceData
- type StopInstanceCall
- type UpdateInstanceCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateInstanceCall ¶
CreateInstanceCall records the parameters of a CreateInstance call
type DeleteInstanceCall ¶
DeleteInstanceCall records the parameters of a DeleteInstance call
type ExecCall ¶
type ExecCall struct {
Instance *types.Instance
Options types.ExecOptions
}
ExecCall records the parameters of an Exec call
type FakeHealthController ¶
type FakeHealthController struct {
// contains filtered or unexported fields
}
FakeHealthController is a lightweight test double for HealthController
func NewFakeHealthController ¶
func NewFakeHealthController() *FakeHealthController
func (*FakeHealthController) AddInstance ¶
func (*FakeHealthController) AddedInstances ¶
func (f *FakeHealthController) AddedInstances() []struct { Service *types.Service Instance *types.Instance }
Helper accessors for assertions
func (*FakeHealthController) GetHealthStatus ¶
func (f *FakeHealthController) GetHealthStatus(ctx context.Context, instanceID string) (*types.InstanceHealthStatus, error)
func (*FakeHealthController) RemoveInstance ¶
func (f *FakeHealthController) RemoveInstance(instanceID string) error
func (*FakeHealthController) RemovedInstanceIDs ¶
func (f *FakeHealthController) RemovedInstanceIDs() []string
func (*FakeHealthController) Start ¶
func (f *FakeHealthController) Start(ctx context.Context) error
func (*FakeHealthController) Stop ¶
func (f *FakeHealthController) Stop() error
type FakeInstanceController ¶
type FakeInstanceController struct {
CreateInstanceCalls []CreateInstanceCall
RecreateInstanceCalls []RecreateInstanceCall
UpdateInstanceCalls []UpdateInstanceCall
StopInstanceCalls []StopInstanceCall
DeleteInstanceCalls []DeleteInstanceCall
RestartInstanceCalls []RestartInstanceCall
GetStatusCalls []string // Instance IDs
GetLogsCalls []string // Instance IDs
ExecCalls []ExecCall
// Custom behavior options
CreateInstanceFunc func(ctx context.Context, service *types.Service, instanceName string) (*types.Instance, error)
RecreateInstanceFunc func(ctx context.Context, service *types.Service, instance *types.Instance) (*types.Instance, error)
UpdateInstanceFunc func(ctx context.Context, service *types.Service, instance *types.Instance) error
StopInstanceFunc func(ctx context.Context, instance *types.Instance) error
DeleteInstanceFunc func(ctx context.Context, instance *types.Instance) error
RestartInstanceFunc func(ctx context.Context, instance *types.Instance, reason InstanceRestartReason) error
GetStatusFunc func(ctx context.Context, instance *types.Instance) (*types.InstanceStatusInfo, error)
GetLogsFunc func(ctx context.Context, instance *types.Instance, opts types.LogOptions) (io.ReadCloser, error)
ExecFunc func(ctx context.Context, instance *types.Instance, options types.ExecOptions) (types.ExecStream, error)
// Default error responses
CreateInstanceError error
RecreateInstanceError error
UpdateInstanceError error
StopInstanceError error
DeleteInstanceError error
RestartInstanceError error
GetStatusError error
GetLogsError error
ExecError error
// Mock responses
ExecStdout []byte
ExecStderr []byte
ExecExitCode int
// contains filtered or unexported fields
}
FakeInstanceController implements the InstanceController interface for testing purposes
func NewFakeInstanceController ¶
func NewFakeInstanceController() *FakeInstanceController
NewFakeInstanceController creates a new test instance controller
func (*FakeInstanceController) AddInstance ¶
func (c *FakeInstanceController) AddInstance(instance *types.Instance)
AddInstance allows tests to add an instance directly to the controller's storage
func (*FakeInstanceController) CreateInstance ¶
func (c *FakeInstanceController) CreateInstance(ctx context.Context, service *types.Service, instanceName string) (*types.Instance, error)
CreateInstance records a call to create an instance and returns a predefined or mocked result
func (*FakeInstanceController) DeleteInstance ¶
func (c *FakeInstanceController) DeleteInstance(ctx context.Context, instance *types.Instance) error
DeleteInstance records a call to delete an instance
func (*FakeInstanceController) Exec ¶
func (c *FakeInstanceController) Exec(ctx context.Context, instance *types.Instance, options types.ExecOptions) (types.ExecStream, error)
Exec records a call to execute a command in an instance
func (*FakeInstanceController) GetInstance ¶
func (c *FakeInstanceController) GetInstance(ctx context.Context, namespace, instanceID string) (*types.Instance, error)
GetInstance allows tests to retrieve an instance from the controller's storage
func (*FakeInstanceController) GetInstanceByID ¶
func (c *FakeInstanceController) GetInstanceByID(ctx context.Context, namespace, instanceID string) (*types.Instance, error)
GetInstanceByID implements InstanceController interface
func (*FakeInstanceController) GetInstanceLogs ¶
func (c *FakeInstanceController) GetInstanceLogs(ctx context.Context, instance *types.Instance, opts types.LogOptions) (io.ReadCloser, error)
GetInstanceLogs records a call to get instance logs
func (*FakeInstanceController) GetInstanceStatus ¶
func (c *FakeInstanceController) GetInstanceStatus(ctx context.Context, instance *types.Instance) (*types.InstanceStatusInfo, error)
GetInstanceStatus records a call to get instance status
func (*FakeInstanceController) ListInstances ¶
func (c *FakeInstanceController) ListInstances(ctx context.Context, namespace string) ([]*types.Instance, error)
ListInstances records a call to list instances
func (*FakeInstanceController) ListRunningInstances ¶
func (*FakeInstanceController) RecreateInstance ¶
func (c *FakeInstanceController) RecreateInstance(ctx context.Context, service *types.Service, instance *types.Instance) (*types.Instance, error)
RecreateInstance records a call to recreate an instance
func (*FakeInstanceController) Reset ¶
func (c *FakeInstanceController) Reset()
Reset clears all recorded calls and stored instances
func (*FakeInstanceController) RestartInstance ¶
func (c *FakeInstanceController) RestartInstance(ctx context.Context, instance *types.Instance, reason InstanceRestartReason) error
RestartInstance records a call to restart an instance
func (*FakeInstanceController) StopInstance ¶
StopInstance records a call to stop an instance
func (*FakeInstanceController) UpdateInstance ¶
func (c *FakeInstanceController) UpdateInstance(ctx context.Context, service *types.Service, instance *types.Instance) error
UpdateInstance records a call to update an instance
type FakeScalingController ¶
type FakeScalingController struct {
// contains filtered or unexported fields
}
FakeScalingController is a lightweight test double for ScalingController
func NewFakeScalingController ¶
func NewFakeScalingController() *FakeScalingController
func (*FakeScalingController) CompleteOperation ¶
func (f *FakeScalingController) CompleteOperation(namespace, serviceName string)
func (*FakeScalingController) CreateScalingOperation ¶
func (f *FakeScalingController) CreateScalingOperation(ctx context.Context, service *types.Service, params types.ScalingOperationParams) error
func (*FakeScalingController) CreatedOperations ¶
func (f *FakeScalingController) CreatedOperations() []*types.ScalingOperation
Helpers for tests
func (*FakeScalingController) GetActiveOperation ¶
func (f *FakeScalingController) GetActiveOperation(ctx context.Context, namespace, serviceName string) (*types.ScalingOperation, error)
func (*FakeScalingController) Start ¶
func (f *FakeScalingController) Start(ctx context.Context) error
func (*FakeScalingController) Stop ¶
func (f *FakeScalingController) Stop()
type HealthController ¶
type HealthController interface {
// Start the health controller
Start(ctx context.Context) error
// Stop the health controller
Stop() error
// AddInstance adds an instance to be monitored
AddInstance(service *types.Service, instance *types.Instance) error
// RemoveInstance removes an instance from monitoring
RemoveInstance(instanceID string) error
// GetHealthStatus gets the current health status of an instance
GetHealthStatus(ctx context.Context, instanceID string) (*types.InstanceHealthStatus, error)
}
HealthController monitors instance health
func NewHealthController ¶
func NewHealthController(logger log.Logger, store store.Store, runnerManager manager.IRunnerManager, instanceController InstanceController) HealthController
NewHealthController creates a new health controller
type InstanceController ¶
type InstanceController interface {
// GetInstanceByID gets an instance by ID
GetInstanceByID(ctx context.Context, namespace, instanceID string) (*types.Instance, error)
// ListInstances lists all instances in a namespace
ListInstances(ctx context.Context, namespace string) ([]*types.Instance, error)
// GetRunningInstances lists all running instances
ListRunningInstances(ctx context.Context, namespace string) ([]*types.Instance, error)
// CreateInstance creates a new instance for a service
CreateInstance(ctx context.Context, service *types.Service, instanceName string) (*types.Instance, error)
// RecreateInstance recreates an instance
RecreateInstance(ctx context.Context, service *types.Service, instance *types.Instance) (*types.Instance, error)
// UpdateInstance updates an existing instance
UpdateInstance(ctx context.Context, service *types.Service, instance *types.Instance) error
// StopInstance stops an instance temporarily but keeps it in the store
StopInstance(ctx context.Context, instance *types.Instance) error
// DeleteInstance marks an instance for deletion and cleans up runner resources
// The instance will remain in the store with Deleted status until garbage collection
DeleteInstance(ctx context.Context, instance *types.Instance) error
// GetInstanceStatus gets the current status of an instance
GetInstanceStatus(ctx context.Context, instance *types.Instance) (*types.InstanceStatusInfo, error)
// GetInstanceLogs gets logs for an instance
GetInstanceLogs(ctx context.Context, instance *types.Instance, opts types.LogOptions) (io.ReadCloser, error)
// RestartInstance restarts an instance with respect to the service's restart policy
RestartInstance(ctx context.Context, instance *types.Instance, reason InstanceRestartReason) error
// Exec executes a command in a running instance
// Returns an ExecStream for bidirectional communication
Exec(ctx context.Context, instance *types.Instance, options types.ExecOptions) (types.ExecStream, error)
// contains filtered or unexported methods
}
InstanceController manages instance lifecycle
func NewInstanceController ¶
func NewInstanceController(store store.Store, runnerManager manager.IRunnerManager, logger log.Logger) InstanceController
NewInstanceController creates a new instance controller
type InstanceRestartReason ¶
type InstanceRestartReason string
const ( InstanceRestartReasonManual InstanceRestartReason = "manual" InstanceRestartReasonHealthCheckFailure InstanceRestartReason = "health-check-failure" InstanceRestartReasonUpdate InstanceRestartReason = "update" InstanceRestartReasonFailure InstanceRestartReason = "failure" )
type RecreateInstanceCall ¶
RecreateInstanceCall records the parameters of a RecreateInstance call
type RestartInstanceCall ¶
type RestartInstanceCall struct {
Instance *types.Instance
Reason InstanceRestartReason
}
RestartInstanceCall records the parameters of a RestartInstance call
type RunningInstance ¶
type RunningInstance struct {
Instance *types.Instance
IsOrphaned bool
Runner types.RunnerType
}
RunningInstance represents an instance found running in a runner
type ScalingController ¶
type ScalingController interface {
// Start the scaling controller
Start(ctx context.Context) error
// Stop the scaling controller
Stop()
// CreateScalingOperation creates a new scaling operation
CreateScalingOperation(ctx context.Context, service *types.Service, params types.ScalingOperationParams) error
// GetActiveOperation gets the active scaling operation for a service
GetActiveOperation(ctx context.Context, namespace, serviceName string) (*types.ScalingOperation, error)
}
ScalingController manages scaling operations for services
func NewScalingController ¶
func NewScalingController(store store.Store, logger log.Logger) ScalingController
NewScalingController creates a new scaling controller
type ServiceController ¶
type ServiceController interface {
Start(ctx context.Context) error
Stop() error
GetServiceStatus(ctx context.Context, namespace, name string) (*types.ServiceStatusInfo, error)
UpdateServiceStatus(ctx context.Context, service *types.Service, status types.ServiceStatus) error
GetServiceLogs(ctx context.Context, namespace, name string, opts types.LogOptions) (io.ReadCloser, error)
ExecInService(ctx context.Context, namespace, serviceName string, options types.ExecOptions) (types.ExecStream, error)
RestartService(ctx context.Context, namespace, serviceName string) error
StopService(ctx context.Context, namespace, serviceName string) error
DeleteService(ctx context.Context, request *types.DeletionRequest) (*types.DeletionResponse, error)
GetDeletionStatus(ctx context.Context, namespace, name string) (*types.DeletionOperation, error)
// contains filtered or unexported methods
}
ServiceController implements the Controller interface for service management
func NewServiceController ¶
func NewServiceController( store store.Store, instanceController InstanceController, healthController HealthController, scalingController ScalingController, logger log.Logger, ) (ServiceController, error)
NewServiceController creates a new service controller
type ServiceInstanceData ¶
type ServiceInstanceData struct {
Instances []types.Instance
OrphanedInstances []*types.Instance // Actual orphaned instance objects
}
ServiceInstanceData contains instances and orphaned instance information
type StopInstanceCall ¶
StopInstanceCall records the parameters of a StopInstance call