Documentation
¶
Overview ¶
Package events provides a thread-safe event bus for the Doki daemon.
It mirrors the semantics of the Docker /events endpoint and the Podman /libpod/events endpoint: subscribers receive a continuous stream of typed events, optionally filtered by type/event/labels. Subscribers can be removed at any time without affecting other subscribers. The bus is the single source of truth for all container/image/network/volume/system lifecycle notifications.
Index ¶
- type Action
- type Actor
- type Bus
- func (b *Bus) Close()
- func (b *Bus) Count() int
- func (b *Bus) Publish(e Event)
- func (b *Bus) PublishContainer(action Action, id, name string, attrs map[string]string)
- func (b *Bus) PublishImage(action Action, id string, attrs map[string]string)
- func (b *Bus) PublishNetwork(action Action, id, name string)
- func (b *Bus) PublishPod(action Action, id, name string)
- func (b *Bus) PublishSystem(action Action, attrs map[string]string)
- func (b *Bus) PublishVolume(action Action, name string)
- func (b *Bus) Subscribe(f Filter, bufferSize int) *Subscription
- func (b *Bus) SubscribeContext(ctx context.Context, f Filter, bufferSize int) *Subscription
- type Event
- type Filter
- type Subscription
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action string
Action is the specific action that occurred. Values are the canonical Moby/Podman strings ("start", "die", "create", ...).
const ( ActionCreate Action = "create" ActionStart Action = "start" ActionStop Action = "stop" ActionDie Action = "die" ActionKill Action = "kill" ActionPause Action = "pause" ActionUnpause Action = "unpause" ActionRestart Action = "restart" ActionDestroy Action = "destroy" ActionRemove Action = "destroy" ActionRename Action = "rename" ActionResize Action = "resize" ActionArchive Action = "archive" ActionExport Action = "export" ActionImport Action = "import" ActionPull Action = "pull" ActionPush Action = "push" ActionTag Action = "tag" ActionUntag Action = "untag" ActionDelete Action = "delete" ActionConnect Action = "connect" ActionDisconnect Action = "disconnect" ActionPrune Action = "prune" ActionHealth Action = "health_status" ActionOOM Action = "oom" ActionExec Action = "exec_create" ActionExecDie Action = "exec_die" )
type Actor ¶
type Actor struct {
ID string `json:"ID"`
Attributes map[string]string `json:"Attributes,omitempty"`
}
Actor is the object the event refers to.
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is the central event multiplexer.
func (*Bus) Close ¶
func (b *Bus) Close()
Close shuts down the bus and closes all subscriber channels.
func (*Bus) Publish ¶
Publish sends an event to all matching subscribers. It never blocks and never returns an error: if a subscriber's buffer is full, the event is dropped for that subscriber (and the bus increments a per-subscriber drop counter visible via Stats).
func (*Bus) PublishContainer ¶
PublishContainer is a convenience for container events.
func (*Bus) PublishImage ¶
PublishImage publishes an image event.
func (*Bus) PublishNetwork ¶
PublishNetwork publishes a network event.
func (*Bus) PublishPod ¶
PublishPod publishes a pod event.
func (*Bus) PublishSystem ¶
PublishSystem publishes a system-level event.
func (*Bus) PublishVolume ¶
PublishVolume publishes a volume event.
func (*Bus) Subscribe ¶
func (b *Bus) Subscribe(f Filter, bufferSize int) *Subscription
Subscribe registers a new subscriber with the given filter and buffer size. Buffer size 0 means unbuffered; otherwise the channel will buffer up to bufferSize events before dropping the slowest subscribers' messages (publishing is non-blocking).
func (*Bus) SubscribeContext ¶
SubscribeContext is like Subscribe but additionally closes the subscription when ctx is cancelled.
type Event ¶
type Event struct {
Type Type `json:"Type"`
Action Action `json:"Action"`
Actor Actor `json:"Actor"`
Status string `json:"status,omitempty"`
ID string `json:"id,omitempty"`
From string `json:"from,omitempty"`
Time int64 `json:"time"`
TimeNano int64 `json:"timeNano"`
Scope string `json:"scope,omitempty"`
Attributes map[string]string `json:"Actor.Attributes,omitempty"`
}
Event is a single lifecycle notification.
type Filter ¶
type Filter struct {
Type []string `json:"type,omitempty"`
Event []string `json:"event,omitempty"`
Container []string `json:"container,omitempty"`
Image []string `json:"image,omitempty"`
Network []string `json:"network,omitempty"`
Volume []string `json:"volume,omitempty"`
Pod []string `json:"pod,omitempty"`
Label []string `json:"label,omitempty"`
}
Filter narrows the events a subscriber receives. Each non-empty field is AND-combined; each list within a field is OR-combined.
func FilterFromJSON ¶
FilterFromJSON parses a Docker-style filter JSON. The format is a map of arrays of strings: `{"status":["running"],"label":["a=b"]}`.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a handle returned by Subscribe that the caller must Close() to stop receiving events.
func (*Subscription) Channel ¶
func (s *Subscription) Channel() <-chan Event
Channel returns the receive-only channel for events.
func (*Subscription) Close ¶
func (s *Subscription) Close() error
Close releases the subscription. Idempotent.
func (*Subscription) ID ¶
func (s *Subscription) ID() uint64
ID returns the subscription's unique identifier.