Documentation
¶
Index ¶
- func DrainStatsBody(r io.ReadCloser)
- type Client
- func (c *Client) Close() error
- func (c *Client) ExecCapture(ctx context.Context, containerID string, cmd []string) (output string, exitCode int, err error)
- func (c *Client) FetchLogLines(ctx context.Context, containerID string, tail int) ([]string, error)
- func (c *Client) FetchStatesByID(ctx context.Context, ids []string) (map[string]ContainerState, error)
- func (c *Client) Inspect(ctx context.Context, containerID string) (*InspectInfo, error)
- func (c *Client) ListAll(ctx context.Context) ([]ContainerInfo, error)
- func (c *Client) Logs(ctx context.Context, containerID string, lines int) (string, error)
- func (c *Client) StartEventsCh(ctx context.Context) (<-chan ContainerEvent, <-chan error)
- func (c *Client) StartLogStreamCh(ctx context.Context, containerID string, tail int) <-chan LogLineMsg
- func (c *Client) StartPollCh(ctx context.Context) <-chan PollMsg
- func (c *Client) Stats(ctx context.Context, containerID string) (*StatsInfo, error)
- type ContainerEvent
- type ContainerInfo
- type ContainerState
- type HealthInfo
- type HealthcheckSpec
- type InspectInfo
- type LogLineMsg
- type PollMsg
- type ProbeResult
- type StatsInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrainStatsBody ¶ added in v0.4.0
func DrainStatsBody(r io.ReadCloser)
DrainStatsBody is a test helper closing unused readers.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the official Docker SDK client.
func NewClient ¶
NewClient creates a Client connected to the local Docker daemon via DOCKER_HOST / Unix socket.
func (*Client) ExecCapture ¶ added in v0.4.0
func (c *Client) ExecCapture(ctx context.Context, containerID string, cmd []string) (output string, exitCode int, err error)
ExecCapture runs cmd inside containerID and returns combined stdout/stderr plus the exit code.
func (*Client) FetchLogLines ¶ added in v0.2.0
FetchLogLines returns the last tail lines of stdout+stderr as a slice (oldest first).
func (*Client) FetchStatesByID ¶ added in v0.2.0
func (c *Client) FetchStatesByID(ctx context.Context, ids []string) (map[string]ContainerState, error)
FetchStatesByID returns observed states keyed by container ID. IDs not found in the current list are omitted; callers keep the last known state.
func (*Client) Inspect ¶ added in v0.4.0
Inspect returns distilled inspect data, cached for 2s per container. Polling must not inspect every container — callers request on demand.
func (*Client) ListAll ¶ added in v0.2.0
func (c *Client) ListAll(ctx context.Context) ([]ContainerInfo, error)
ListAll returns every container on the daemon (running and stopped).
func (*Client) StartEventsCh ¶ added in v0.5.0
func (c *Client) StartEventsCh(ctx context.Context) (<-chan ContainerEvent, <-chan error)
StartEventsCh streams container lifecycle events until ctx is cancelled. Callers should keep Poll as a fallback when the events stream is unavailable.
func (*Client) StartLogStreamCh ¶ added in v0.2.0
func (c *Client) StartLogStreamCh(ctx context.Context, containerID string, tail int) <-chan LogLineMsg
StartLogStreamCh launches a goroutine that tails container logs with Follow enabled. The channel closes when ctx is cancelled, the stream ends, or an error occurs.
func (*Client) StartPollCh ¶ added in v0.2.0
StartPollCh launches a background goroutine that polls Docker every 500 ms and sends a PollMsg on the returned channel. The goroutine exits when ctx is cancelled and the channel is then closed.
type ContainerEvent ¶ added in v0.5.0
type ContainerEvent struct {
Time time.Time
Action string
ContainerID string
Image string
Name string
Project string
Service string
ExitCode string
Signal string
OOMKilled bool
Health string
Attributes map[string]string
}
ContainerEvent is a distilled docker events message for containers.
type ContainerInfo ¶ added in v0.2.0
type ContainerInfo struct {
ID string
Names []string
Image string
Labels map[string]string
State ContainerState
ExitCode *int // parsed from Status "Exited (N) ..."; nil while running
Status string // raw human-readable Docker status string
Ports []string // formatted "8080:80/tcp" (published) or "80/tcp" (exposed only)
Created int64 // unix seconds, from container.Summary.Created
}
ContainerInfo holds discovered container metadata from a single list call.
type ContainerState ¶
type ContainerState int
ContainerState represents the observed lifecycle state of a container.
const ( StatePending ContainerState = iota // waiting on a dependency; not yet started StateStarting // container exists, health check running StateHealthy // running and health check passing (or no healthcheck) StateUnhealthy // health check explicitly failing StateExited // stopped with non-zero exit code )
The set of observable container lifecycle states, ordered from not-yet-started to terminal.
func (ContainerState) String ¶
func (s ContainerState) String() string
type HealthInfo ¶ added in v0.4.0
type HealthInfo struct {
Status string // starting|healthy|unhealthy
FailingStreak int
Log []ProbeResult
}
HealthInfo captures the runtime health state and probe history.
type HealthcheckSpec ¶ added in v0.4.0
type HealthcheckSpec struct {
Test []string
Interval, Timeout, StartPeriod time.Duration
Retries int
}
HealthcheckSpec captures the configured healthcheck from docker inspect.
type InspectInfo ¶ added in v0.4.0
type InspectInfo struct {
ID, RestartPolicy, Error string
StartedAt, FinishedAt time.Time
RestartCount int
OOMKilled bool
Env []string
Health *HealthInfo
Healthcheck *HealthcheckSpec
}
InspectInfo is the normalized subset of docker inspect used by the doctor package. It intentionally avoids exposing Docker SDK structs to callers.
type LogLineMsg ¶ added in v0.2.0
LogLineMsg carries one line from a streaming log follow, or anaconda terminal error.
type PollMsg ¶ added in v0.2.0
type PollMsg struct {
Containers []ContainerInfo
}
PollMsg is a Bubble Tea message emitted each poll cycle with full container metadata.
type ProbeResult ¶ added in v0.4.0
ProbeResult is one healthcheck probe result from docker inspect.