pubsub

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

pipeline status coverage report GoDoc Go Report Card

eh-appengine-pubsub

eh-pubsub-appengine is and eventbus based on Google Pub/Sub for Event Horizon CQRS/ES toolkit for Go.

This event bus is based on the Push Method for Pub/Sub which allows you to use this in the App Engine Standard Environment.

Usage

See the Event Horizon example folder for a few examples to get you started and replace the event bus

Development

To develop eh-appengine-pubsub you need to have Docker and Docker Compose installed.

To start all required services and run all tests, simply run make:

make

To manually start services for local development outside Docker:

make services

You can then run either one of the following:

make test
make _test
go test ./...

or use your favourite IDE to run your tests with a Cloud Firestore emulator in the background.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBus

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

EventBus is a local event bus that delegates handling of published events to all matching registered handlers, in order of registration.

func NewEventBus

func NewEventBus(projectID string, config *SubscriberConfig, opts ...option.ClientOption) (*EventBus, error)

NewEventBus creates an EventBus with optional GCP connection settings

func NewEventBusWithClient

func NewEventBusWithClient(config *SubscriberConfig, client *pubsub.Client) (*EventBus, error)

NewEventBusWithClient created and EventBus with provided config and client

func (*EventBus) AddHandler

func (b *EventBus) AddHandler(ctx context.Context, m eh.EventMatcher, h eh.EventHandler) error

AddHandler implements the AddHandler method of the eventhorizon.EventBus interface.

func (*EventBus) Errors

func (b *EventBus) Errors() <-chan eh.EventBusError

Errors implements the Errors method of the eventhorizon.EventBus interface.

func (*EventBus) HandleEvent

func (b *EventBus) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the eventhorizon.EventBus interface.

func (*EventBus) HandlerType

func (b *EventBus) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventBus interface.

func (*EventBus) Wait

func (b *EventBus) Wait()

type Muxer

type Muxer interface {
	// Handle registers the handler function for the given pattern.
	Handle(pattern string, handlerFunc http.Handler)

	// ServeHTTP dispatches the requests to the appropriate handler
	// whose method matches the request method and whose patter most
	// closely matches the request URL.
	ServeHTTP(http.ResponseWriter, *http.Request)
}

Muxer is a HTTP request multiplexer that can be used if you need

func NewDefaultMuxer

func NewDefaultMuxer(handler http.Handler) Muxer

NewDefaultMuxer returns a muxer implementation that forwards requests starting with "/_ah/push-handlers" to this muxer, but all other requests to handler. If handler is nil, nothing will happen.

func NewMuxer

func NewMuxer(prefixPattern string, handler http.Handler) Muxer

NewMuxer returns a Muxer implementation that matches prefixPattern against this muxer, and all other requests are forwarded to handler.

type Option

type Option func(*EventBus) error

Option is an option setter used to configure creation.

func WithCodec

func WithCodec(codec eh.EventCodec) Option

WithCodec uses the specified codec for encoding events.

type SubscriberConfig

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

SubscriberConfig is a configuration for push subscribers

func NewDefaultSubscriberConfig

func NewDefaultSubscriberConfig(appID, host, schema string, mux Muxer) *SubscriberConfig

func NewSubscriberConfig

func NewSubscriberConfig(appID, host, schema, endpointBase string, mux Muxer) *SubscriberConfig

func (*SubscriberConfig) Endpoint

func (c *SubscriberConfig) Endpoint(typ string) string

func (*SubscriberConfig) Handle

func (c *SubscriberConfig) Handle(typ string, h http.Handler)

func (*SubscriberConfig) SubscriberID

func (c *SubscriberConfig) SubscriberID(typ string) string

Jump to

Keyboard shortcuts

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