event

package
v0.0.0-...-14558bb Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler interface {
	HandleEvent(*api.EventMsg)
	GetHandlerType() string
	GetClient() EventHandlerClient
}

type EventHandlerClient

type EventHandlerClient interface {
	// TODO: CallOption?
	HandleEvent(ctx context.Context, in *api.EventMsg, opts ...grpc.CallOption) (*api.EventResponse, error)
}

type EventService

type EventService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Type EventService is responsible for event publishing and processing. Currently, it has a hard-coded map of events to event handlers. When an event is published, EventService gets the event off its input channel and matches the event with the correct handler function. Handler functions are started in their own goroutines.

func NewEventService

func NewEventService(cfg *config.EventConfig, cf *secureconn.Factory) *EventService

func (*EventService) Publish

func (svc *EventService) Publish(event *api.EventMsg)

Other services call publish on the event service api in order to notify the rest of the system of an event. Services should fire events in their own goroutines so that they are not blocked if the event input queue is full.

func (*EventService) Start

func (svc *EventService) Start(r Registry) error

Start the event processor that listens on the in channel and fires off event handlers for each event received.

func (*EventService) Stop

func (svc *EventService) Stop(ctx context.Context) error

type Registry

type Registry map[string][]string

Jump to

Keyboard shortcuts

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