Documentation
¶
Overview ¶
Package cliwrap re-exports the canonical types from internal/cwtypes via Go type aliases, so the public API surface is unchanged.
Index ¶
- Constants
- Variables
- type ExceedAction
- type LogOptions
- type Manager
- func (m *Manager) ChildPIDs() map[string]int
- func (m *Manager) Events() event.Bus
- func (m *Manager) List() []mgmt.ListEntry
- func (m *Manager) Register(spec Spec) (ProcessHandle, error)
- func (m *Manager) Shutdown(ctx context.Context) error
- func (m *Manager) StatusOf(id string) (mgmt.ListEntry, error)
- func (m *Manager) Stop(ctx context.Context, id string) error
- type ManagerOption
- type ProcessHandle
- type ResourceLimits
- type RestartPolicy
- type SandboxSpec
- type Spec
- type SpecBuilder
- func (b *SpecBuilder) Build() (Spec, error)
- func (b *SpecBuilder) WithEnv(k, v string) *SpecBuilder
- func (b *SpecBuilder) WithLogOptions(o LogOptions) *SpecBuilder
- func (b *SpecBuilder) WithMaxRestarts(n int) *SpecBuilder
- func (b *SpecBuilder) WithResourceLimits(l ResourceLimits) *SpecBuilder
- func (b *SpecBuilder) WithRestart(p RestartPolicy) *SpecBuilder
- func (b *SpecBuilder) WithRestartBackoff(d time.Duration) *SpecBuilder
- func (b *SpecBuilder) WithSandbox(s *SandboxSpec) *SpecBuilder
- func (b *SpecBuilder) WithStdin(m StdinMode) *SpecBuilder
- func (b *SpecBuilder) WithStopTimeout(d time.Duration) *SpecBuilder
- func (b *SpecBuilder) WithWorkDir(path string) *SpecBuilder
- type SpecValidationError
- type State
- type Status
- type StdinMode
Constants ¶
const ( RestartNever = cwtypes.RestartNever RestartOnFailure = cwtypes.RestartOnFailure RestartAlways = cwtypes.RestartAlways ExceedWarn = cwtypes.ExceedWarn ExceedThrottle = cwtypes.ExceedThrottle ExceedKill = cwtypes.ExceedKill StdinNone = cwtypes.StdinNone StdinPipe = cwtypes.StdinPipe StdinInherit = cwtypes.StdinInherit StatePending = cwtypes.StatePending StateStarting = cwtypes.StateStarting StateRunning = cwtypes.StateRunning StateStopping = cwtypes.StateStopping StateStopped = cwtypes.StateStopped StateCrashed = cwtypes.StateCrashed StateRestarting = cwtypes.StateRestarting StateFailed = cwtypes.StateFailed )
Re-exported constants.
Variables ¶
var ( ErrProcessNotFound = errors.New("cliwrap: process not found") ErrProcessAlreadyExists = errors.New("cliwrap: process already exists") ErrProcessNotRunning = errors.New("cliwrap: process not running") ErrProcessAlreadyRunning = errors.New("cliwrap: process already running") ErrManagerShuttingDown = errors.New("cliwrap: manager is shutting down") ErrManagerClosed = errors.New("cliwrap: manager is closed") ErrSandboxProviderNotFound = errors.New("cliwrap: sandbox provider not registered") ErrAgentSpawnFailed = errors.New("cliwrap: failed to spawn agent") ErrHandshakeTimeout = errors.New("cliwrap: handshake timeout") ErrStopTimeout = errors.New("cliwrap: stop timeout") // ErrInvalidSpec is re-exported from cwtypes so that // SpecValidationError.Is(ErrInvalidSpec) works across both packages. ErrInvalidSpec = cwtypes.ErrInvalidSpec )
Sentinel errors.
Functions ¶
This section is empty.
Types ¶
type ExceedAction ¶
type ExceedAction = cwtypes.ExceedAction
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type LogOptions ¶
type LogOptions = cwtypes.LogOptions
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the top-level library entry point.
func NewManager ¶
func NewManager(opts ...ManagerOption) (*Manager, error)
NewManager constructs a Manager with the given options.
func (*Manager) ChildPIDs ¶
ChildPIDs returns a snapshot of running (process ID -> child PID) pairs. Processes that are not in StateRunning are omitted.
func (*Manager) Events ¶
Events returns the Manager's event bus. Subscribers receive lifecycle, log, and reliability events. The bus is lazily created on first call.
func (*Manager) Register ¶
func (m *Manager) Register(spec Spec) (ProcessHandle, error)
Register validates and registers a process spec.
type ManagerOption ¶
type ManagerOption func(*Manager)
ManagerOption mutates a Manager during construction.
func WithAgentPath ¶
func WithAgentPath(path string) ManagerOption
WithAgentPath sets the absolute path to the cliwrap-agent binary.
func WithRuntimeDir ¶
func WithRuntimeDir(path string) ManagerOption
WithRuntimeDir sets the directory for per-process state (WAL, logs).
type ProcessHandle ¶
type ProcessHandle interface {
ID() string
Spec() Spec
Status() Status
Start(ctx context.Context) error
Stop(ctx context.Context) error
Close(ctx context.Context) error
}
ProcessHandle is the user-facing handle to a managed process.
type ResourceLimits ¶
type ResourceLimits = cwtypes.ResourceLimits
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type RestartPolicy ¶
type RestartPolicy = cwtypes.RestartPolicy
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type SandboxSpec ¶
type SandboxSpec = cwtypes.SandboxSpec
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type Spec ¶
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type SpecBuilder ¶
type SpecBuilder struct {
// contains filtered or unexported fields
}
SpecBuilder is a fluent constructor for Spec. Errors surface only from Build.
func NewSpec ¶
func NewSpec(id, cmd string, args ...string) *SpecBuilder
NewSpec starts a new SpecBuilder for the given ID, command, and arguments.
func (*SpecBuilder) Build ¶
func (b *SpecBuilder) Build() (Spec, error)
Build validates and returns the Spec.
func (*SpecBuilder) WithEnv ¶
func (b *SpecBuilder) WithEnv(k, v string) *SpecBuilder
WithEnv sets a single environment variable.
func (*SpecBuilder) WithLogOptions ¶
func (b *SpecBuilder) WithLogOptions(o LogOptions) *SpecBuilder
WithLogOptions attaches log storage options.
func (*SpecBuilder) WithMaxRestarts ¶
func (b *SpecBuilder) WithMaxRestarts(n int) *SpecBuilder
WithMaxRestarts limits how many restarts will be attempted.
func (*SpecBuilder) WithResourceLimits ¶
func (b *SpecBuilder) WithResourceLimits(l ResourceLimits) *SpecBuilder
WithResourceLimits attaches resource caps.
func (*SpecBuilder) WithRestart ¶
func (b *SpecBuilder) WithRestart(p RestartPolicy) *SpecBuilder
WithRestart sets the restart policy.
func (*SpecBuilder) WithRestartBackoff ¶
func (b *SpecBuilder) WithRestartBackoff(d time.Duration) *SpecBuilder
WithRestartBackoff sets the initial backoff delay between restarts.
func (*SpecBuilder) WithSandbox ¶
func (b *SpecBuilder) WithSandbox(s *SandboxSpec) *SpecBuilder
WithSandbox attaches a sandbox spec.
func (*SpecBuilder) WithStdin ¶
func (b *SpecBuilder) WithStdin(m StdinMode) *SpecBuilder
WithStdin selects how the child's stdin is wired.
func (*SpecBuilder) WithStopTimeout ¶
func (b *SpecBuilder) WithStopTimeout(d time.Duration) *SpecBuilder
WithStopTimeout sets the SIGTERM → SIGKILL grace period.
func (*SpecBuilder) WithWorkDir ¶
func (b *SpecBuilder) WithWorkDir(path string) *SpecBuilder
WithWorkDir sets the working directory for the child process.
type SpecValidationError ¶
type SpecValidationError = cwtypes.SpecValidationError
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.
type State ¶
Type aliases — these are transparent to callers. Users continue to write cliwrap.State, cliwrap.Spec, etc.