eventpubsub

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidType = errors.New("invalid event type")
	ErrInvalidData = errors.New("invalid event data")
)

Functions

This section is empty.

Types

type DecodeInputFunc

type DecodeInputFunc func(context.Context, Event) (input interface{}, err error)

DecodeInputFunc extracts a user-domain input object from an event. It's designed to be used in event handlers, for subscriber-side endpoints.

type Event

type Event interface {
	Type() string
	Data() interface{}
}

type Handler

type Handler interface {
	Handle(ctx context.Context, event Event) error
}

type HandlerSet

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

func NewHandlerSet

func NewHandlerSet() *HandlerSet

func (*HandlerSet) Add

func (hs *HandlerSet) Add(typ string, handler Handler)

func (*HandlerSet) Handle

func (hs *HandlerSet) Handle(ctx context.Context, event Event) error

type Publisher

type Publisher interface {
	Publish(ctx context.Context, typ string, data interface{}) error
}

type Subscriber

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

Subscriber wraps an endpoint and implements Handler.

func NewSubscriber

func NewSubscriber(e endpoint.Endpoint, dec DecodeInputFunc) *Subscriber

NewSubscriber constructs a new subscriber, which implements Handler and wraps the provided endpoint.

func (*Subscriber) Handle

func (s *Subscriber) Handle(ctx context.Context, event Event) error

Handle implements Handler.

Jump to

Keyboard shortcuts

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