interfaces

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package interfaces provides the interfaces for the eventer package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatorMiddleware

type AggregatorMiddleware interface {
	AggregateMiddleware(h message.HandlerFunc) message.HandlerFunc
}

AggregatorMiddleware is an interface that allows the eventer to add middleware to the router

type Consumer

type Consumer interface {
	Register(Registrar)
}

Consumer is an interface implemented by components which wish to consume events. Once a component has implemented the consumer interface, it can be registered with an event router using the HandleAll interface.

type Handler

type Handler = message.NoPublishHandlerFunc

Handler is an alias for the watermill handler type, which is both wordy and may be detail we don't want to expose.

type Interface

type Interface interface {
	Publisher
	Registrar
	Service
}

Interface is a combination of the Publisher, Registrar, and Service interfaces. This is handy when spawning the eventer in a single function for easy setup.

type Publisher

type Publisher interface {
	// Publish implements message.Publisher
	Publish(topic string, messages ...*message.Message) error
}

Publisher is an interface implemented by components which wish to publish events.

type Registrar

type Registrar interface {
	// Register requests that the message router calls handler for each message on topic.
	// It is valid to call Register multiple times with the same topic and different handler
	// functions, or to call Register multiple times with different topics and the same
	// handler function.  It's allowed to call Register with both argument the same, but
	// then events will be delivered twice to the handler, which is probably not what you want.
	Register(topic string, handler Handler, mdw ...message.HandlerMiddleware)
}

Registrar provides an interface which allows an event router to expose itself to event consumers.

type Service

type Service interface {
	// ConsumeEvents allows registration of multiple consumers easily
	ConsumeEvents(consumers ...Consumer)
	// Close closes the router
	Close() error
	// Run runs the router, blocks until the router is closed
	Run(ctx context.Context) error

	// Running returns a channel which allows you to wait until the
	// event router has started.
	Running() chan struct{}
}

Service is an interface that allows the eventer to orchestrate the consumption and publication of events, as well as start and stop the event router.

Directories

Path Synopsis
Package mock_interfaces is a generated GoMock package.
Package mock_interfaces is a generated GoMock package.

Jump to

Keyboard shortcuts

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