Documentation
¶
Overview ¶
Package process provides process execution implementations.
Index ¶
- func IsDockerAvailable(ctx context.Context) bool
- func ReadPIDFile(path string) (int, error)
- type ContainerError
- type DockerExecutorImpl
- func (e *DockerExecutorImpl) ContainerLogs(ctx context.Context, containerID string, lines int) ([]string, error)
- func (e *DockerExecutorImpl) ExecInContainer(ctx context.Context, containerID string, command []string) ([]byte, error)
- func (e *DockerExecutorImpl) FindContainerByName(ctx context.Context, name string) (ports.DockerHandle, error)
- func (e *DockerExecutorImpl) ImageExists(ctx context.Context, image string) bool
- func (e *DockerExecutorImpl) IsRunning(handle ports.ProcessHandle) bool
- func (e *DockerExecutorImpl) Kill(handle ports.ProcessHandle) error
- func (e *DockerExecutorImpl) Logs(handle ports.ProcessHandle, lines int) ([]string, error)
- func (e *DockerExecutorImpl) PullImage(ctx context.Context, image string) error
- func (e *DockerExecutorImpl) RemoveContainer(ctx context.Context, containerID string, force bool) error
- func (e *DockerExecutorImpl) RunContainer(ctx context.Context, config ports.ContainerConfig) (ports.DockerHandle, error)
- func (e *DockerExecutorImpl) Start(ctx context.Context, cmd ports.Command) (ports.ProcessHandle, error)
- func (e *DockerExecutorImpl) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error
- func (e *DockerExecutorImpl) StopContainer(ctx context.Context, containerID string, timeout time.Duration) error
- type ExecutionError
- type ImageError
- type LocalExecutor
- func (e *LocalExecutor) FindProcessByPID(pid int, logPath string) (ports.ProcessHandle, error)
- func (e *LocalExecutor) IsRunning(handle ports.ProcessHandle) bool
- func (e *LocalExecutor) Kill(handle ports.ProcessHandle) error
- func (e *LocalExecutor) Logs(handle ports.ProcessHandle, lines int) ([]string, error)
- func (e *LocalExecutor) Start(ctx context.Context, cmd ports.Command) (ports.ProcessHandle, error)
- func (e *LocalExecutor) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error
- type NotRunningError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDockerAvailable ¶
IsDockerAvailable checks if Docker is available and running.
Types ¶
type ContainerError ¶
ContainerError is returned when Docker container operations fail.
func (*ContainerError) Error ¶
func (e *ContainerError) Error() string
type DockerExecutorImpl ¶
type DockerExecutorImpl struct {
*LocalExecutor // Embed for local process fallback
}
DockerExecutorImpl implements DockerExecutor for Docker container execution.
func NewDockerExecutor ¶
func NewDockerExecutor() *DockerExecutorImpl
NewDockerExecutor creates a new DockerExecutorImpl.
func (*DockerExecutorImpl) ContainerLogs ¶
func (e *DockerExecutorImpl) ContainerLogs(ctx context.Context, containerID string, lines int) ([]string, error)
ContainerLogs retrieves container logs.
func (*DockerExecutorImpl) ExecInContainer ¶
func (e *DockerExecutorImpl) ExecInContainer(ctx context.Context, containerID string, command []string) ([]byte, error)
ExecInContainer executes a command inside a running container.
func (*DockerExecutorImpl) FindContainerByName ¶
func (e *DockerExecutorImpl) FindContainerByName(ctx context.Context, name string) (ports.DockerHandle, error)
FindContainerByName finds a container by name and returns a handle.
func (*DockerExecutorImpl) ImageExists ¶
func (e *DockerExecutorImpl) ImageExists(ctx context.Context, image string) bool
ImageExists checks if a Docker image exists locally.
func (*DockerExecutorImpl) IsRunning ¶
func (e *DockerExecutorImpl) IsRunning(handle ports.ProcessHandle) bool
IsRunning checks if a process is running.
func (*DockerExecutorImpl) Kill ¶
func (e *DockerExecutorImpl) Kill(handle ports.ProcessHandle) error
Kill forcefully terminates a process.
func (*DockerExecutorImpl) Logs ¶
func (e *DockerExecutorImpl) Logs(handle ports.ProcessHandle, lines int) ([]string, error)
Logs retrieves logs from a process.
func (*DockerExecutorImpl) PullImage ¶
func (e *DockerExecutorImpl) PullImage(ctx context.Context, image string) error
PullImage pulls a Docker image.
func (*DockerExecutorImpl) RemoveContainer ¶
func (e *DockerExecutorImpl) RemoveContainer(ctx context.Context, containerID string, force bool) error
RemoveContainer removes a Docker container.
func (*DockerExecutorImpl) RunContainer ¶
func (e *DockerExecutorImpl) RunContainer(ctx context.Context, config ports.ContainerConfig) (ports.DockerHandle, error)
RunContainer starts a Docker container.
func (*DockerExecutorImpl) Start ¶
func (e *DockerExecutorImpl) Start(ctx context.Context, cmd ports.Command) (ports.ProcessHandle, error)
Start launches a process (delegates to local executor for non-Docker commands).
func (*DockerExecutorImpl) Stop ¶
func (e *DockerExecutorImpl) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error
Stop gracefully stops a process.
func (*DockerExecutorImpl) StopContainer ¶
func (e *DockerExecutorImpl) StopContainer(ctx context.Context, containerID string, timeout time.Duration) error
StopContainer stops a Docker container.
type ExecutionError ¶
ExecutionError is returned when process execution fails.
func (*ExecutionError) Error ¶
func (e *ExecutionError) Error() string
type ImageError ¶
ImageError is returned when Docker image operations fail.
func (*ImageError) Error ¶
func (e *ImageError) Error() string
type LocalExecutor ¶
type LocalExecutor struct{}
LocalExecutor implements ProcessExecutor for local process execution.
func NewLocalExecutor ¶
func NewLocalExecutor() *LocalExecutor
NewLocalExecutor creates a new LocalExecutor.
func (*LocalExecutor) FindProcessByPID ¶
func (e *LocalExecutor) FindProcessByPID(pid int, logPath string) (ports.ProcessHandle, error)
FindProcessByPID finds a process by PID and returns a handle. Note: The returned handle has done=nil because there's no monitoring goroutine for externally-discovered processes. Stop() will fall back to polling-based termination detection when done is nil, and Wait() will return immediately.
func (*LocalExecutor) IsRunning ¶
func (e *LocalExecutor) IsRunning(handle ports.ProcessHandle) bool
IsRunning checks if a process is running.
func (*LocalExecutor) Kill ¶
func (e *LocalExecutor) Kill(handle ports.ProcessHandle) error
Kill forcefully terminates a process.
func (*LocalExecutor) Logs ¶
func (e *LocalExecutor) Logs(handle ports.ProcessHandle, lines int) ([]string, error)
Logs retrieves the last N lines from the process log.
func (*LocalExecutor) Start ¶
func (e *LocalExecutor) Start(ctx context.Context, cmd ports.Command) (ports.ProcessHandle, error)
Start launches a new process.
func (*LocalExecutor) Stop ¶
func (e *LocalExecutor) Stop(ctx context.Context, handle ports.ProcessHandle, timeout time.Duration) error
Stop gracefully stops a process with timeout.
type NotRunningError ¶
type NotRunningError struct {
PID int
}
NotRunningError is returned when a process is not running.
func (*NotRunningError) Error ¶
func (e *NotRunningError) Error() string