Documentation
¶
Index ¶
- type Client
- func (c *Client) Close() 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) ListAll(ctx context.Context) ([]ContainerInfo, error)
- func (c *Client) Logs(ctx context.Context, containerID string, lines int) (string, error)
- func (c *Client) StartLogStreamCh(ctx context.Context, containerID string, tail int) <-chan LogLineMsg
- func (c *Client) StartPollCh(ctx context.Context) <-chan PollMsg
- type ContainerInfo
- type ContainerState
- type LogLineMsg
- type PollMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) 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) 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) 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 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 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.