eventbus

package
v1.14.8 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStarted = errors.New("event broker has not been started")
)

Functions

This section is empty.

Types

type EventBus

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

EventBus contains the main logic of running an event broker for Vault. Start() must be called before the EventBus will accept events for sending.

func NewEventBus

func NewEventBus(logger hclog.Logger) (*EventBus, error)

func (*EventBus) SendInternal

func (bus *EventBus) SendInternal(_ context.Context, ns *namespace.Namespace, pluginInfo *logical.EventPluginInfo, eventType logical.EventType, data *logical.EventData) error

SendInternal sends an event to the event bus and routes it to all relevant subscribers. This function does *not* wait for all subscribers to acknowledge before returning. This function is meant to be used by trusted internal code, so it can specify details like the namespace and plugin info. Events from plugins should be routed through WithPlugin(), which will populate the namespace and plugin info automatically. The context passed in is currently ignored to ensure that the event is sent if the context is short-lived, such as with an HTTP request context.

func (*EventBus) SetSendTimeout

func (bus *EventBus) SetSendTimeout(timeout time.Duration)

SetSendTimeout sets the timeout of sending events. If the events are not accepted by the underlying channel before this timeout, then the channel closed.

func (*EventBus) Start

func (bus *EventBus) Start()

Start starts the event bus, allowing events to be written. It is not possible to stop or restart the event bus. It is safe to call Start() multiple times.

func (*EventBus) Subscribe

func (bus *EventBus) Subscribe(ctx context.Context, ns *namespace.Namespace, pattern string) (<-chan *eventlogger.Event, context.CancelFunc, error)

func (*EventBus) WithPlugin

func (bus *EventBus) WithPlugin(ns *namespace.Namespace, eventPluginInfo *logical.EventPluginInfo) (*pluginEventBus, error)

Jump to

Keyboard shortcuts

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