Documentation
¶
Index ¶
- type ContainerInfo
- type ContainerSpec
- type ContainerStatus
- type DockerClient
- type FileChange
- type PortMapping
- type Service
- func (s *Service) AttachInteractiveSession(ctx context.Context, containerID string) error
- func (s *Service) CheckHealth(ctx context.Context) error
- func (s *Service) Close() error
- func (s *Service) ContainerDiff(ctx context.Context, containerID string) ([]FileChange, error)
- func (s *Service) ContainerExists(ctx context.Context, name string) (ContainerInfo, error)
- func (s *Service) CreateContainer(ctx context.Context, spec *ContainerSpec) (ContainerInfo, error)
- func (s *Service) FindProjectContainer(ctx context.Context, account, projectPath, projectHash string) (*ContainerInfo, error)
- func (s *Service) ListReactorContainers(ctx context.Context) ([]ContainerInfo, error)
- func (s *Service) ProvisionContainer(ctx context.Context, spec *ContainerSpec) (ContainerInfo, error)
- func (s *Service) ProvisionContainerWithCleanup(ctx context.Context, spec *ContainerSpec, forceCleanup bool) (ContainerInfo, error)
- func (s *Service) RemoveContainer(ctx context.Context, containerID string) error
- func (s *Service) ResizeTerminal(ctx context.Context, containerID string, size TTYSize) error
- func (s *Service) StartContainer(ctx context.Context, containerID string) error
- func (s *Service) StopContainer(ctx context.Context, containerID string) error
- type TTYSize
- type TerminalState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct {
ID string
Name string
Status ContainerStatus
Image string
}
ContainerInfo holds information about a container
type ContainerSpec ¶
type ContainerStatus ¶
type ContainerStatus string
ContainerStatus represents the status of a container
const ( StatusRunning ContainerStatus = "running" StatusStopped ContainerStatus = "stopped" StatusNotFound ContainerStatus = "not_found" )
type DockerClient ¶
type DockerClient interface {
// Health and connection management
Ping(ctx context.Context) (types.Ping, error)
Close() error
// Core container lifecycle operations - CRITICAL PATH
ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
// Session and interaction operations
ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error)
ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
// Exec operations for session management
ContainerExecCreate(ctx context.Context, containerID string, options types.ExecConfig) (types.IDResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
// Additional operations for discovery and debugging
ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error)
ContainerKill(ctx context.Context, containerID string, signal string) error
ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error
ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error
// Image management
ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
}
DockerClient defines the interface for Docker API operations needed by our Service. This interface allows us to mock the Docker client in unit tests while using the real Docker client in production.
The interface is focused on the critical path operations needed for container recovery.
type FileChange ¶
type FileChange struct {
Kind string // A (Added), D (Deleted), C (Changed)
Path string // Path to the changed file
}
FileChange represents a filesystem change in a container
type PortMapping ¶
ContainerSpec defines the specification for creating a container PortMapping represents a port forwarding configuration
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages Docker daemon interactions
func NewService ¶
NewService creates a new Docker service with a real Docker client
func NewServiceWithClient ¶
func NewServiceWithClient(client DockerClient) *Service
NewServiceWithClient creates a new Docker service with the provided client. This constructor is primarily used for testing with mock clients.
func (*Service) AttachInteractiveSession ¶
AttachInteractiveSession attaches to a running container with enhanced TTY support
func (*Service) CheckHealth ¶
CheckHealth verifies Docker daemon is accessible and running
func (*Service) ContainerDiff ¶
ContainerDiff returns filesystem changes made to a container
func (*Service) ContainerExists ¶
ContainerExists checks if a container with the given name exists
func (*Service) CreateContainer ¶
func (s *Service) CreateContainer(ctx context.Context, spec *ContainerSpec) (ContainerInfo, error)
CreateContainer creates a new container with the given specifications
func (*Service) FindProjectContainer ¶
func (s *Service) FindProjectContainer(ctx context.Context, account, projectPath, projectHash string) (*ContainerInfo, error)
FindProjectContainer finds a container for a specific project path
func (*Service) ListReactorContainers ¶
func (s *Service) ListReactorContainers(ctx context.Context) ([]ContainerInfo, error)
ListReactorContainers returns all containers that match the reactor naming pattern
func (*Service) ProvisionContainer ¶
func (s *Service) ProvisionContainer(ctx context.Context, spec *ContainerSpec) (ContainerInfo, error)
ProvisionContainer implements the three-phase container recovery strategy: 1. Check for running container with deterministic name 2. Check for stopped container and restart it 3. Create new container only if needed For discovery containers, always removes existing containers to ensure clean environment
func (*Service) ProvisionContainerWithCleanup ¶
func (s *Service) ProvisionContainerWithCleanup(ctx context.Context, spec *ContainerSpec, forceCleanup bool) (ContainerInfo, error)
ProvisionContainerWithCleanup allows specifying whether to always clean up existing containers
func (*Service) RemoveContainer ¶
RemoveContainer removes a container (must be stopped first)
func (*Service) ResizeTerminal ¶
ResizeTerminal provides external interface for terminal resizing
func (*Service) StartContainer ¶
StartContainer starts a stopped container
type TerminalState ¶
type TerminalState struct {
OriginalState *term.State
RawModeSet bool
Size TTYSize
SignalChan chan os.Signal
ResizeChan chan TTYSize
// contains filtered or unexported fields
}
TerminalState manages terminal state and cleanup
func NewTerminalState ¶
func NewTerminalState() *TerminalState
NewTerminalState creates a new terminal state manager
func (*TerminalState) Cleanup ¶
func (ts *TerminalState) Cleanup() error
Cleanup restores terminal state
func (*TerminalState) GetTerminalSize ¶
func (ts *TerminalState) GetTerminalSize() (TTYSize, error)
GetTerminalSize returns current terminal dimensions
func (*TerminalState) Setup ¶
func (ts *TerminalState) Setup() error
Setup configures terminal for interactive session
func (*TerminalState) StartSignalHandling ¶
func (ts *TerminalState) StartSignalHandling()
StartSignalHandling begins signal forwarding to container