events

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Action

type Action uint16
const (
	ActionFileWritten Action = (1 << iota)
	ActionFileCreated
	ActionFileDeleted
	ActionFileRenamed

	ActionContainerCreate
	ActionContainerStart
	ActionContainerUnpause

	ActionContainerKill
	ActionContainerStop
	ActionContainerPause
	ActionContainerDie
	ActionContainerDestroy

	ActionForceReload
)

func (Action) IsContainerPause added in v0.11.0

func (a Action) IsContainerPause() bool

func (Action) IsContainerStart added in v0.11.0

func (a Action) IsContainerStart() bool

func (Action) IsContainerStop added in v0.11.0

func (a Action) IsContainerStop() bool

func (Action) String

func (a Action) String() string

type Event

type Event struct {
	Type            EventType
	ActorName       string            // docker: container name, file: relative file path
	ActorID         string            // docker: container id, file: empty
	ActorAttributes map[string]string // docker: container labels, file: empty
	Action          Action
}

func (Event) String

func (e Event) String() string

type EventQueue

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

func NewEventQueue

func NewEventQueue(queueTask *task.Task, flushInterval time.Duration, onFlush OnFlushFunc, onError OnErrorFunc) *EventQueue

NewEventQueue returns a new EventQueue with the given queueTask, flushInterval, onFlush and onError.

The returned EventQueue will start a goroutine to flush events in the queue when the flushInterval is reached.

The onFlush function is called when the flushInterval is reached and the queue is not empty,

The onError function is called when an error received from the errCh, or panic occurs in the onFlush function. Panic will cause a E.ErrPanicRecv error.

flushTask.Finish must be called after the flush is done, but the onFlush function can return earlier (e.g. run in another goroutine).

If task is canceled before the flushInterval is reached, the events in queue will be discarded.

func (*EventQueue) Start

func (e *EventQueue) Start(eventCh <-chan Event, errCh <-chan gperr.Error)

type EventType

type EventType string
const (
	EventTypeDocker EventType = "docker"
	EventTypeFile   EventType = "file"
)

type OnErrorFunc

type OnErrorFunc = func(err gperr.Error)

type OnFlushFunc

type OnFlushFunc = func(events []Event)

Jump to

Keyboard shortcuts

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