eventdispatch

package
v0.30.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package eventdispatch passes the events of each topic to its handler in api.EventsOpts.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedTopic = errors.New("unsupported event topic")

ErrUnsupportedTopic is returned by Handle for an event of a topic that is not supported.

Functions

func ForwardingGuarded

func ForwardingGuarded(opts *api.EventsOpts, forward func(topic string) bool) *api.EventsOpts

ForwardingGuarded returns a copy of opts whose handlers forward events only when forward allows their topic. It leaves missing topic handlers nil so events can reach the generic handler. It copies the topics slice and never changes opts, so guards for different clients do not stack.

func Handle

func Handle(ctx context.Context, opts *api.EventsOpts, topic string, data []byte) error

Handle decodes the data of an event with the given topic, as sent on the events stream, and passes it to the topic's specific handler in the options, or failing that to their generic handler. It returns an error if the topic is not supported or the data does not decode.

func HasTopicHandler

func HasTopicHandler(opts *api.EventsOpts, topic string) bool

HasTopicHandler reports whether the options carry a handler specific to the given topic.

func Supports

func Supports(topic string) bool

Supports reports whether events of the given topic can be handled. It is to be used in place of apiv1.SupportedEventTopics, which is an exported map that callers can change.

Types

This section is empty.

Jump to

Keyboard shortcuts

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