events

package
v0.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package events is the engine's event bus: what happened to containers, images and volumes, as GET /events streams it (Docker's EventMessage: Type, Action, Actor{ID, Attributes}, time). The bus keeps a bounded history for `since` and gives each subscriber a bounded queue; a subscriber that falls that far behind is cut off (its channel closed, Lost set) rather than slowing the engine down.

Index

Constants

View Source
const (
	Container = "container"
	Image     = "image"
	Volume    = "volume"
	Network   = "network"
)

Types of objects that emit events.

View Source
const (
	// History is how many past events the bus keeps for `since`.
	History = 1024
	// Queue is how many events a subscriber may be behind.
	Queue = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus struct {
	// contains filtered or unexported fields
}

Bus fans events out. The zero value is not usable; use New.

func New

func New() *Bus

New returns an empty bus.

func (*Bus) Publish

func (b *Bus) Publish(e Event)

Publish records e (stamping its time if unset) and delivers it.

func (*Bus) Subscribe

func (b *Bus) Subscribe(since time.Time, filter func(Event) bool) ([]Event, *Sub)

Subscribe returns the kept events at or after since that pass filter (nil: all), and a subscription for what comes next; nothing is lost or repeated between the two.

type Event

type Event struct {
	Type, Action string
	// ID is the actor: a container ID, an image ID or reference, a
	// volume name.
	ID         string
	Attributes map[string]string
	Time       time.Time
}

Event is one thing that happened.

type Sub

type Sub struct {
	C <-chan Event
	// contains filtered or unexported fields
}

Sub is a subscription.

func (*Sub) Close

func (s *Sub) Close()

Close ends the subscription.

func (*Sub) Lost

func (s *Sub) Lost() bool

Lost reports whether the subscription was cut off for falling behind.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL