events

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

Broker manages event subscriptions and distribution

func NewBroker

func NewBroker() *Broker

NewBroker creates a new event broker

func (*Broker) Publish

func (b *Broker) Publish(event *Event)

Publish publishes an event to all subscribers

func (*Broker) Start

func (b *Broker) Start()

Start begins the broker's event distribution loop

func (*Broker) Stop

func (b *Broker) Stop()

Stop stops the broker

func (*Broker) Subscribe

func (b *Broker) Subscribe() Subscriber

Subscribe creates a new subscription and returns a channel

func (*Broker) SubscriberCount

func (b *Broker) SubscriberCount() int

SubscriberCount returns the number of active subscribers

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(sub Subscriber)

Unsubscribe removes a subscription

type Event

type Event struct {
	ID        string
	Type      EventType
	Timestamp time.Time
	Message   string
	Metadata  map[string]string
}

Event represents a cluster event

type EventType

type EventType string

EventType represents the type of event

const (
	EventServiceCreated EventType = "service.created"
	EventServiceUpdated EventType = "service.updated"
	EventServiceDeleted EventType = "service.deleted"
	EventTaskCreated    EventType = "task.created"
	EventTaskFailed     EventType = "task.failed"
	EventTaskCompleted  EventType = "task.completed"
	EventNodeJoined     EventType = "node.joined"
	EventNodeLeft       EventType = "node.left"
	EventNodeDown       EventType = "node.down"
	EventSecretCreated  EventType = "secret.created"
	EventSecretDeleted  EventType = "secret.deleted"
	EventVolumeCreated  EventType = "volume.created"
	EventVolumeDeleted  EventType = "volume.deleted"
)

type Subscriber

type Subscriber chan *Event

Subscriber is a channel that receives events

Jump to

Keyboard shortcuts

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