pubsubx

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedMessageType = errors.New("unexpected message type")

Functions

func Cancel

func Cancel(ctx context.Context)

func GetHandlerName

func GetHandlerName(handler Handler) string

func NewManager

func NewManager() *manager

func Publish

func Publish(ctx context.Context, topic string, message interface{}) error

func Subscribe

func Subscribe(ctx context.Context, topic string, handler Handler)

func WithCancel

func WithCancel(ctx context.Context) context.Context

func WithManager

func WithManager(ctx context.Context, manager Manager) context.Context

Types

type Handler

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

type HandlerFunc

type HandlerFunc func(ctx context.Context, message interface{}) error

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(ctx context.Context, message interface{}) error

type Manager

type Manager interface {
	Subscribe(ctx context.Context, topic string, handler Handler)
	Publish(ctx context.Context, topic string, message interface{}) error
}
var Default Manager = NewManager()

func GetManager

func GetManager(ctx context.Context) Manager

Jump to

Keyboard shortcuts

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