events

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package events provides interfaces and types for working with events

Index

Constants

View Source
const (
	TaskCreate         = eventsv1.EventType_TaskCreate
	TaskDelete         = eventsv1.EventType_TaskDelete
	TaskUpdate         = eventsv1.EventType_TaskUpdate
	TaskStart          = eventsv1.EventType_TaskStart
	TaskGet            = eventsv1.EventType_TaskGet
	TaskList           = eventsv1.EventType_TaskList
	TaskKill           = eventsv1.EventType_TaskKill
	TaskStop           = eventsv1.EventType_TaskStop
	TaskPatch          = eventsv1.EventType_TaskPatch
	NodeGet            = eventsv1.EventType_NodeGet
	NodeCreate         = eventsv1.EventType_NodeCreate
	NodeDelete         = eventsv1.EventType_NodeDelete
	NodeList           = eventsv1.EventType_NodeList
	NodeUpdate         = eventsv1.EventType_NodeUpdate
	NodeJoin           = eventsv1.EventType_NodeJoin
	NodeForget         = eventsv1.EventType_NodeForget
	NodeConnect        = eventsv1.EventType_NodeConnect
	NodeUpgrade        = eventsv1.EventType_NodeUpgrade
	NodePatch          = eventsv1.EventType_NodePatch
	ContainerSetCreate = eventsv1.EventType_ContainerSetCreate
	ContainerSetDelete = eventsv1.EventType_ContainerSetDelete
	ContainerSetUpdate = eventsv1.EventType_ContainerSetUpdate
	Schedule           = eventsv1.EventType_Schedule
	TailLogsStart      = eventsv1.EventType_TailLogsStart
	TailLogsStop       = eventsv1.EventType_TailLogsStop
	VolumeCreate       = eventsv1.EventType_VolumeCreate
	VolumeDelete       = eventsv1.EventType_VolumeDelete
	VolumeUpdate       = eventsv1.EventType_VolumeUpdate
	VolumeGet          = eventsv1.EventType_VolumeGet
	VolumeList         = eventsv1.EventType_VolumeList
	VolumePatch        = eventsv1.EventType_VolumePatch

	RuntimeTaskExit         = eventsv1.EventType_RuntimeTaskExit
	RuntimeTaskCreate       = eventsv1.EventType_RuntimeTaskCreate
	RuntimeTaskStart        = eventsv1.EventType_RuntimeTaskStart
	RuntimeTaskDelete       = eventsv1.EventType_RuntimeTaskDelete
	RuntimeTaskIO           = eventsv1.EventType_RuntimeTaskIO
	RuntimeTaskOOM          = eventsv1.EventType_RuntimeTaskOOM
	RuntimeTaskExecAdded    = eventsv1.EventType_RuntimeTaskExecAdded
	RuntimeTaskExecStarted  = eventsv1.EventType_RuntimeTaskExecStarted
	RuntimeTaskPaused       = eventsv1.EventType_RuntimeTaskPaused
	RuntimeTaskResumed      = eventsv1.EventType_RuntimeTaskResumed
	RuntimeTaskCheckpointed = eventsv1.EventType_RuntimeTaskCheckpointed
	RuntimeSnapshotPrepare  = eventsv1.EventType_RuntimeSnapshotPrepare
	RuntimeSnapshotCommit   = eventsv1.EventType_RuntimeSnapshotCommit
	RuntimeSnapshotRemove   = eventsv1.EventType_RuntimeSnapshotRemove
	RuntimeNamespaceCreate  = eventsv1.EventType_RuntimeNamespaceCreate
	RuntimeNamespaceUpdate  = eventsv1.EventType_RuntimeNamespaceUpdate
	RuntimeNamespaceDelete  = eventsv1.EventType_RuntimeNamespaceDelete
	RuntimeImageCreate      = eventsv1.EventType_RuntimeImageCreate
	RuntimeImageUpdate      = eventsv1.EventType_RuntimeImageUpdate
	RuntimeImageDelete      = eventsv1.EventType_RuntimeImageDelete
	RuntimeContainerCreate  = eventsv1.EventType_RuntimeContainerCreate
	RuntimeContainerUpdate  = eventsv1.EventType_RuntimeContainerUpdate
	RuntimeContainerDelete  = eventsv1.EventType_RuntimeContainerDelete
	RuntimeContentCreate    = eventsv1.EventType_RuntimeContentCreate
	RuntimeContentDelete    = eventsv1.EventType_RuntimeContentDelete

	LeaseAcquiered = eventsv1.EventType_LeaseAcquired
	LeaseExpired   = eventsv1.EventType_LeaseExpired
	LeaseRenewed   = eventsv1.EventType_LeaseRenewed
	LeaseReleased  = eventsv1.EventType_LeaseReleased
	LeaseDeleted   = eventsv1.EventType_LeaseDeleted

	ConditionReported = eventsv1.EventType_ConditionReported
)

Variables

Functions

func NewEvent

func NewEvent(evType eventsv1.EventType, obj Object, eventLabels ...map[string]string) *eventsv1.Event

func NewHandler added in v0.0.18

func NewHandler[T any, PT interface {
	*T
	proto.Message
}](
	h func(context.Context, PT) error,
) func(context.Context, proto.Message) error

func NewRequest

func NewRequest(evType eventsv1.EventType, obj Object, labels ...map[string]string) *eventsv1.PublishRequest

Types

type ConditionHandlerFunc added in v0.0.13

type ConditionHandlerFunc func(context.Context, *typesv1.ConditionReport, string) error

type Exchange

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

func NewExchange

func NewExchange(opts ...NewExchangeOption) *Exchange

func (*Exchange) AddForwarder added in v0.0.11

func (e *Exchange) AddForwarder(forwarder Forwarder)

AddForwarder adds a forwarder to this Exchange, forwarding any message on Publish()

func (*Exchange) Forward

func (e *Exchange) Forward(ctx context.Context, ev *eventsv1.Event) error

Forward publishes the event using the publishers added to this exchange. Implements Forwarder.

func (*Exchange) On

func (e *Exchange) On(ev eventsv1.EventType, f HandlerFunc)

On registers a handler func for a certain event type

func (*Exchange) Once

func (e *Exchange) Once(ev eventsv1.EventType, f HandlerFunc)

Once attaches a handler to the specified event type. The handler func is only executed once

func (*Exchange) Publish

func (e *Exchange) Publish(ctx context.Context, ev *eventsv1.Event) error

Publish publishes an event of a certain type

func (*Exchange) Subscribe

func (e *Exchange) Subscribe(ctx context.Context, t ...eventsv1.EventType) chan *eventsv1.Event

Subscribe subscribes to events of a certain event type

func (*Exchange) Unsubscribe

func (e *Exchange) Unsubscribe(context.Context, eventsv1.EventType) error

Unsubscribe implements Subscriber.

type Forwarder

type Forwarder interface {
	Forward(context.Context, *eventsv1.Event) error
}

type Handler added in v0.0.13

type Handler interface {
	Handle(context.Context, *eventsv1.Event) error
}

type HandlerFunc

type HandlerFunc func(context.Context, *eventsv1.Event) error

func Handle added in v0.0.13

func Handle(h HandlerFunc) HandlerFunc

func HandleErrors added in v0.0.13

func HandleErrors(log logger.Logger, h HandlerFunc) HandlerFunc

func HandleLease added in v0.0.13

func HandleLease(h LeaseHandlerFunc) HandlerFunc

func HandleNew added in v0.0.18

func HandleNew[T any, PT interface {
	*T
	proto.Message
}](h func(context.Context, PT) error) HandlerFunc

func HandleNode added in v0.0.13

func HandleNode(h NodeHandlerFunc) HandlerFunc

func HandleNodeUpradeReq added in v0.0.18

func HandleNodeUpradeReq(h NodeUpgradeHandlerFunc) HandlerFunc

func HandleScheduling added in v0.0.13

func HandleScheduling(h SchedulingHandlerFunc) HandlerFunc

func HandleTask added in v0.0.13

func HandleTask(h TaskHandlerFunc) HandlerFunc

func HandleTasks added in v0.0.13

func HandleTasks(h ...TaskHandlerFunc) HandlerFunc

func HandleVolume added in v0.0.13

func HandleVolume(h VolumeHandlerFunc) HandlerFunc

type LeaseHandlerFunc added in v0.0.13

type LeaseHandlerFunc func(context.Context, *leasesv1.Lease) error

type LogExchange

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

func (*LogExchange) CloseKey

func (lx *LogExchange) CloseKey(key LogKey)

CloseKey closes all subscriber channels for the given key and removes the topic.

func (*LogExchange) Publish

func (lx *LogExchange) Publish(entry *logsv1.LogEntry)

Publish sends the entry to all subscribers on the exchange

func (*LogExchange) Subscribe

func (lx *LogExchange) Subscribe(key LogKey) <-chan *logsv1.LogEntry

Subscribe adds a subscription on the exchange using key as the ID

func (*LogExchange) Unsubscribe

func (lx *LogExchange) Unsubscribe(key LogKey, ch <-chan *logsv1.LogEntry)

Unsubscribe removes subscription from the exchange identified by key

type LogKey

type LogKey struct {
	NodeID    string
	TaskID    string
	SessionID string
}

type NewExchangeOption

type NewExchangeOption func(*Exchange)

func WithExchangeLogger

func WithExchangeLogger(l logger.Logger) NewExchangeOption

type NodeHandlerFunc added in v0.0.13

type NodeHandlerFunc func(context.Context, *nodesv1.Node) error

type NodeUpgradeHandlerFunc added in v0.0.18

type NodeUpgradeHandlerFunc func(context.Context, *nodesv1.UpgradeRequest) error

type Object

type Publisher

type Publisher interface {
	Publish(context.Context, *eventsv1.Event) error
}

type SchedulingHandlerFunc added in v0.0.13

type SchedulingHandlerFunc func(context.Context, *tasksv1.Task, *nodesv1.Node) error

type Subscriber

type Subscriber interface {
	Subscribe(context.Context, ...eventsv1.EventType) chan *eventsv1.Event
	Unsubscribe(context.Context, eventsv1.EventType) error
}

type TaskHandlerFunc added in v0.0.13

type TaskHandlerFunc func(context.Context, *tasksv1.Task) error

func HandleEach added in v0.0.13

func HandleEach(f ...func()) TaskHandlerFunc

type VolumeHandlerFunc added in v0.0.13

type VolumeHandlerFunc func(context.Context, *volumesv1.Volume) error

Jump to

Keyboard shortcuts

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