event

package
v0.0.0-...-3dc0db1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithNumWorkers

func WithNumWorkers(n int) func(d *Dispatcher)

WithNumWorkers allows providing a specific number of workers for a Dispatcher instance.

Types

type Dispatcher

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

Dispatcher handles a group of workers in charge of processing events that happen in the Hub.

func NewDispatcher

func NewDispatcher(svc *Services, opts ...func(d *Dispatcher)) *Dispatcher

NewDispatcher creates a new Dispatcher instance.

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context, wg *sync.WaitGroup)

Run starts the workers and lets them run until the dispatcher is asked to stop via the context provided.

type Manager

type Manager struct{}

Manager provides an API to manage events.

func NewManager

func NewManager() *Manager

NewManager creates a new Manager instance.

func (*Manager) GetPending

func (m *Manager) GetPending(ctx context.Context, tx pgx.Tx) (*hub.Event, error)

GetPending returns a pending event to be processed if available.

type ManagerMock

type ManagerMock struct {
	mock.Mock
}

ManagerMock is a mock implementation of the EventManager interface.

func (*ManagerMock) GetPending

func (m *ManagerMock) GetPending(ctx context.Context, tx pgx.Tx) (*hub.Event, error)

GetPending implements the EventManager interface.

type Services

type Services struct {
	DB                  hub.DB
	EventManager        hub.EventManager
	SubscriptionManager hub.SubscriptionManager
	WebhookManager      hub.WebhookManager
	NotificationManager hub.NotificationManager
}

Services is a wrapper around several internal services used to handle events processing.

type Worker

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

Worker is in charge of handling events that happen in the Hub.

func NewWorker

func NewWorker(svc *Services) *Worker

NewWorker creates a new Worker instance.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context, wg *sync.WaitGroup)

Run is the main loop of the worker. It calls processEvent periodically until it's asked to stop via the context provided.

Jump to

Keyboard shortcuts

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