Documentation
¶
Index ¶
- type Client
- func (c *Client) ContainerID(ctx context.Context, name string) (string, error)
- func (c *Client) Events(ctx context.Context) (<-chan events.Message, <-chan error)
- func (c *Client) Host() string
- func (c *Client) ListContainers(ctx context.Context) ([]ContainerInfo, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) ResolveIP(ctx context.Context, name, network string) (ip, networkUsed, containerID string, err error)
- type ContainerInfo
- type Resolver
- func (r *Resolver) LastSyncAt() time.Time
- func (r *Resolver) ResolveIP(ctx context.Context, name, network string) (ip, networkUsed, containerID string, err error)
- func (r *Resolver) Run(ctx context.Context)
- func (r *Resolver) State() string
- func (r *Resolver) Watch(name string, cb func()) (unwatch func())
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 是对 Docker SDK 的窄封装:只暴露本工具需要的能力。
func (*Client) ContainerID ¶
ContainerID 按名称/ID 取容器完整 ID(不要求运行中)。
func (*Client) ListContainers ¶
func (c *Client) ListContainers(ctx context.Context) ([]ContainerInfo, error)
ListContainers 返回运行中的容器。
type ContainerInfo ¶
type ContainerInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
State string `json:"state"`
Status string `json:"status"`
IPs map[string]string `json:"ips,omitempty"` // network -> IP
Ports []string `json:"ports,omitempty"`
}
ContainerInfo 是容器列表条目(供 WebUI 选择器使用)。
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver 维护"关注集"(被启用规则引用的容器名)的订阅关系, 订阅 Docker 事件流;任何相关事件触发去抖后的全量刷新回调。
func NewResolver ¶
NewResolver pollInterval <= 0 时关闭兜底轮询。
func (*Resolver) LastSyncAt ¶
LastSyncAt 返回最近一次全量刷新时间(可能为零值)。
func (*Resolver) ResolveIP ¶
func (r *Resolver) ResolveIP(ctx context.Context, name, network string) (ip, networkUsed, containerID string, err error)
ResolveIP 把容器名解析为当前 IP(委托给 Client)。
Click to show internal directories.
Click to hide internal directories.