events

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package events package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventManager

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

EventManager is used to subscribe to database events

func NewEventManager

func NewEventManager(dbClient *db.Client, logger logger.Logger) *EventManager

NewEventManager creates a new instance of EventManager

func (*EventManager) Start

func (e *EventManager) Start(ctx context.Context)

Start will start the event loop for listing to database events

func (*EventManager) Subscribe

func (e *EventManager) Subscribe(subscriptions []Subscription) *Subscriber

Subscribe creates a Subscriber that will be notified of database events based on the specified subscriptions

func (*EventManager) Unsubscribe

func (e *EventManager) Unsubscribe(subscriber *Subscriber)

Unsubscribe removes the subscriber

type Subscriber

type Subscriber struct {
	ID string
	// contains filtered or unexported fields
}

Subscriber is used to subscribe to database events

func (*Subscriber) GetEvent

func (s *Subscriber) GetEvent(ctx context.Context) (*db.Event, error)

GetEvent blocks until an event is available

type Subscription

type Subscription struct {
	Type    SubscriptionType
	ID      string               // Optional ID of resource to subscribe to
	Actions []SubscriptionAction // Empty Actions list will subscribe to all action types
}

Subscription includes the model type to subscribe to

type SubscriptionAction

type SubscriptionAction string

SubscriptionAction type represents the available actions that can be subscribed type

const (
	CreateAction SubscriptionAction = "INSERT"
	UpdateAction SubscriptionAction = "UPDATE"
	DeleteAction SubscriptionAction = "DELETE"
)

SubscriptionAction constants

type SubscriptionType

type SubscriptionType string

SubscriptionType specifies the type of subscription

const (
	JobSubscription             SubscriptionType = "jobs"
	LogStreamSubscription       SubscriptionType = "log_streams"
	RunSubscription             SubscriptionType = "runs"
	WorkspaceSubscription       SubscriptionType = "workspaces"
	RunnerSubscription          SubscriptionType = "runners"
	MaintenanceModeSubscription SubscriptionType = "maintenance_mode"
	RunnerSessionSubscription   SubscriptionType = "runner_sessions"
)

SubscriptionType constants

Jump to

Keyboard shortcuts

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