events

package
v0.0.47 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package events provides the eventer object which is responsible for setting up the watermill router and handling the incoming events

Index

Constants

View Source
const (
	ProviderDeliveryIdKey     = "id"
	ProviderTypeKey           = "provider"
	ProviderSourceKey         = "source"
	GithubWebhookEventTypeKey = "type"

	GoChannelDriver = "go-channel"
	SQLDriver       = "sql"

	DeadLetterQueueTopic = "dead_letter_queue"
	PublishedKey         = "published_at"
)

Metadata added to Messages

View Source
const (
	// TopicQueueEntityEvaluate is the topic for entity evaluation events from webhooks
	TopicQueueEntityEvaluate = "execute.entity.event"
	// TopicQueueEntityFlush is the topic for flushing internal webhook events
	TopicQueueEntityFlush = "flush.entity.event"
	// TopicQueueReconcileRepoInit is the topic for reconciling repository events, i.e. when a new repository is registered
	TopicQueueReconcileRepoInit = "internal.repo.reconciler.event"
	// TopicQueueReconcileProfileInit is the topic for reconciling when a profile is created or updated
	TopicQueueReconcileProfileInit = "internal.profile.init.event"
	// TopicQueueReconcileEntityDelete is the topic for reconciling when an entity is deleted
	TopicQueueReconcileEntityDelete = "internal.entity.delete.event"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatorMiddleware added in v0.0.17

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 added in v0.0.32

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.

func Setup

Setup creates an eventer object which isolates the watermill setup code

type Publisher added in v0.0.37

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 added in v0.0.37

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 common contains common interfaces and types used by the eventer.
Package common contains common interfaces and types used by the eventer.
Package gochannel provides a gochannel implementation of the eventer
Package gochannel provides a gochannel implementation of the eventer
Package mockevents is a generated GoMock package.
Package mockevents is a generated GoMock package.
Package sql provides the eventer implementation for the SQL database.
Package sql provides the eventer implementation for the SQL database.
Package stubs contains stubs for the eventer package
Package stubs contains stubs for the eventer package

Jump to

Keyboard shortcuts

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