Documentation
¶
Index ¶
- type Client
- func (c *Client) API() client.APIClient
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) ConnectWithRetry(ctx context.Context) error
- func (c *Client) DiscoverAll(ctx context.Context) ([]*cmodel.Container, error)
- func (c *Client) DiscoverAllWithLabels(ctx context.Context) ([]*DiscoveryResult, error)
- func (c *Client) FetchLogSnippet(ctx context.Context, containerID string) (string, error)
- func (c *Client) FetchLogs(ctx context.Context, containerID string, lines int, timestamps bool) ([]string, error)
- func (c *Client) GetHealthInfo(ctx context.Context, containerID string) (*HealthInfo, error)
- func (c *Client) Info(ctx context.Context) (system.Info, error)
- func (c *Client) IsConnected() bool
- func (c *Client) Logger() *slog.Logger
- func (c *Client) NetworkInspect(ctx context.Context, networkID string) (network.Inspect, error)
- func (c *Client) NodeList(ctx context.Context) ([]swarm.Node, error)
- func (c *Client) ServiceInspect(ctx context.Context, serviceID string) (swarm.Service, error)
- func (c *Client) ServiceList(ctx context.Context) ([]swarm.Service, error)
- func (c *Client) SetDisconnected()
- func (c *Client) StatsOneShot(ctx context.Context, containerID string) (*ContainerStats, error)
- func (c *Client) StreamEvents(ctx context.Context) <-chan ContainerEvent
- func (c *Client) StreamLogs(ctx context.Context, dockerID string, lines int, timestamps bool) (io.ReadCloser, bool, error)
- func (c *Client) SwarmInspect(ctx context.Context) (swarm.Swarm, error)
- func (c *Client) TaskList(ctx context.Context) ([]swarm.Task, error)
- type ContainerEvent
- type ContainerStats
- type DiscoveredContainer
- type DiscoveryResult
- type HealthInfo
- type PortBindingInfo
- type Runtime
- func (r *Runtime) Client() *Client
- func (r *Runtime) Close() error
- func (r *Runtime) Connect(ctx context.Context) error
- func (r *Runtime) DiscoverAll(ctx context.Context) ([]*cmodel.Container, error)
- func (r *Runtime) DiscoverAllWithLabels(ctx context.Context) ([]*DiscoveryResult, error)
- func (r *Runtime) FetchLogSnippet(ctx context.Context, externalID string) (string, error)
- func (r *Runtime) FetchLogs(ctx context.Context, externalID string, lines int, timestamps bool) ([]string, error)
- func (r *Runtime) GetHealthInfo(ctx context.Context, externalID string) (*pbruntime.HealthInfo, error)
- func (r *Runtime) IsConnected() bool
- func (r *Runtime) Logger() *slog.Logger
- func (r *Runtime) Name() string
- func (r *Runtime) SetDisconnected()
- func (r *Runtime) StatsSnapshot(ctx context.Context, externalID string) (*pbruntime.RawStats, error)
- func (r *Runtime) StreamEvents(ctx context.Context) <-chan pbruntime.RuntimeEvent
- func (r *Runtime) StreamLogs(ctx context.Context, externalID string, lines int, timestamps bool) (io.ReadCloser, error)
- type SecurityConfig
- type SocketUnavailableError
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 Docker SDK client with reconnection logic.
func NewClient ¶
NewClient creates a new Docker client wrapper. If host is empty, it uses the default Docker socket.
func (*Client) ConnectWithRetry ¶
ConnectWithRetry attempts to connect with exponential backoff.
func (*Client) DiscoverAll ¶
DiscoverAll performs a full container list + inspect pass, returning all discovered containers.
func (*Client) DiscoverAllWithLabels ¶
func (c *Client) DiscoverAllWithLabels(ctx context.Context) ([]*DiscoveryResult, error)
DiscoverAllWithLabels is like DiscoverAll but also returns raw Docker labels and security configuration for each container.
func (*Client) FetchLogSnippet ¶
FetchLogSnippet retrieves the last 50 lines of logs for storing as a snippet on exit events.
func (*Client) FetchLogs ¶
func (c *Client) FetchLogs(ctx context.Context, containerID string, lines int, timestamps bool) ([]string, error)
FetchLogs retrieves the last N lines of logs from a container.
func (*Client) GetHealthInfo ¶
GetHealthInfo inspects a container and returns its health check configuration and status.
func (*Client) IsConnected ¶
IsConnected returns the current connection status.
func (*Client) NetworkInspect ¶ added in v1.2.0
NetworkInspect returns details for a network by ID.
func (*Client) ServiceInspect ¶ added in v1.2.0
ServiceInspect returns a single Swarm service with raw data.
func (*Client) ServiceList ¶ added in v1.2.0
ServiceList returns all Swarm services.
func (*Client) SetDisconnected ¶
func (c *Client) SetDisconnected()
SetDisconnected marks the client as disconnected.
func (*Client) StatsOneShot ¶
StatsOneShot retrieves a single stats snapshot for a container. It uses the one-shot API which returns immediately without a priming read.
func (*Client) StreamEvents ¶
func (c *Client) StreamEvents(ctx context.Context) <-chan ContainerEvent
StreamEvents subscribes to Docker container events and sends them to the returned channel. On disconnection, it reconnects with backoff and uses Since to avoid missing events. The caller should cancel ctx to stop the stream.
func (*Client) StreamLogs ¶
func (c *Client) StreamLogs(ctx context.Context, dockerID string, lines int, timestamps bool) (io.ReadCloser, bool, error)
StreamLogs returns an io.ReadCloser that follows container logs in real-time. isTTY indicates whether the container uses a TTY (determines demux needs).
func (*Client) SwarmInspect ¶ added in v1.2.0
SwarmInspect returns the Swarm cluster metadata.
type ContainerEvent ¶
type ContainerEvent struct {
Action string
ExternalID string
Name string
ExitCode string
HealthStatus string
ResourceType string // "container", "service", or "node"
Timestamp time.Time
Labels map[string]string
}
ContainerEvent represents a processed Docker container/service/node event.
type ContainerStats ¶
type ContainerStats = dtypes.StatsResponse
ContainerStats holds the decoded stats response from Docker.
type DiscoveredContainer ¶
DiscoveredContainer holds the result of discovering a single container.
type DiscoveryResult ¶
type DiscoveryResult struct {
Container *cmodel.Container
Labels map[string]string
SecurityConfig *SecurityConfig
}
DiscoveryResult holds a discovered container along with its raw labels for endpoint extraction.
type HealthInfo ¶
type HealthInfo struct {
HasHealthCheck bool
Status *cmodel.HealthStatus
}
HealthInfo holds parsed health check information from a container.
type PortBindingInfo ¶ added in v1.1.0
PortBindingInfo represents a single host port binding.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime implements runtime.Runtime for Docker.
func NewRuntime ¶
NewRuntime creates a Docker runtime wrapping the Docker SDK client.
func (*Runtime) Client ¶
Client returns the underlying Docker client for Docker-specific operations.
func (*Runtime) DiscoverAll ¶
func (*Runtime) DiscoverAllWithLabels ¶
func (r *Runtime) DiscoverAllWithLabels(ctx context.Context) ([]*DiscoveryResult, error)
DiscoverAllWithLabels delegates to the underlying Docker client for endpoint label discovery.
func (*Runtime) FetchLogSnippet ¶
FetchLogSnippet retrieves the last 50 lines of logs for die event snippets. Satisfies container.LogFetcher interface.
func (*Runtime) GetHealthInfo ¶
func (*Runtime) IsConnected ¶
func (*Runtime) SetDisconnected ¶
func (r *Runtime) SetDisconnected()
func (*Runtime) StatsSnapshot ¶
func (*Runtime) StreamEvents ¶
func (r *Runtime) StreamEvents(ctx context.Context) <-chan pbruntime.RuntimeEvent
type SecurityConfig ¶ added in v1.1.0
type SecurityConfig struct {
Privileged bool
NetworkMode string
PortBindings []PortBindingInfo
}
SecurityConfig holds security-relevant fields extracted from Docker's ContainerInspect.
type SocketUnavailableError ¶
type SocketUnavailableError struct {
}
SocketUnavailableError is returned when the Docker socket is not accessible.
func (*SocketUnavailableError) Error ¶
func (e *SocketUnavailableError) Error() string
func (*SocketUnavailableError) Unwrap ¶
func (e *SocketUnavailableError) Unwrap() error