events

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package events supports subscribing to database events.

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 (
	LogStreamSubscription     SubscriptionType = "log_streams"
	PipelineSubscription      SubscriptionType = "pipelines"
	JobSubscription           SubscriptionType = "jobs"
	AgentSubscription         SubscriptionType = "agents"
	AgentSessionSubscription  SubscriptionType = "agent_sessions"
	ActivityEventSubscription SubscriptionType = "activity_events"
	ProjectSubscription       SubscriptionType = "projects"
	CommentSubscription       SubscriptionType = "comments"
	ToDoItemSubscription      SubscriptionType = "todo_items"
)

SubscriptionType constants

Jump to

Keyboard shortcuts

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