events

package
v0.0.66 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 21 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"
	NATSDriver      = "cloudevents-nats"

	DeadLetterQueueTopic = "dead_letter_queue"
	PublishedKey         = "published_at"
)

Metadata added to Messages

View Source
const (
	// TopicQueueOriginatingEntityAdd adds an entity originating from another entity to the database
	TopicQueueOriginatingEntityAdd = "originating.entity.add.event"
	// TopicQueueOriginatingEntityDelete deletes an entity originating from another entity from the database
	TopicQueueOriginatingEntityDelete = "originating.entity.delete.event"
	// TopicQueueGetEntityAndDelete retrieves an entity from the database and schedules it for deletion
	TopicQueueGetEntityAndDelete = "get.entity.delete.event"
	// TopicQueueRefreshEntityByIDAndEvaluate makes sure that entity properties are up-to-date and schedules an evaluation
	TopicQueueRefreshEntityByIDAndEvaluate = "refresh.entity.by.id.evaluate.event"
	// TopicQueueRefreshEntityAndEvaluate makes sure that entity properties are up-to-date and schedules an evaluation
	TopicQueueRefreshEntityAndEvaluate = "refresh.entity.evaluate.event"
	// 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"
	// TopicQueueReconcileEntityAdd is the topic for reconciling when an entity is added
	TopicQueueReconcileEntityAdd = "internal.entity.add.event"
	// TopicQueueRepoReminder is the topic for repo reminder events
	TopicQueueRepoReminder = "repo.reminder.event"
)

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.

func Setup

Setup creates an eventer object which isolates the watermill setup code

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 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 mock_events is a generated GoMock package.
Package mock_events is a generated GoMock package.
Package nats provides a nants+cloudevents implementation of the eventer interface
Package nats provides a nants+cloudevents implementation of the eventer interface
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