bus

package
v0.0.0-...-8444db5 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName service.Name = "bus"
)

Variables

View Source
var (
	ErrPublishTimeout    = errors.New("publish timeout")
	ErrUnexpectedMessage = errors.New("unexpected message")
	ErrNoResponse        = errors.New("no response")
)

Functions

func ServiceProvider

func ServiceProvider(bus Bus) service.Provider

Types

type Bus

type Bus interface {
	Subscribe(ctx context.Context, ns MessageNamespace, msgType MessageType) (<-chan Message, error)
	Unsubscribe(ctx context.Context, ns MessageNamespace, msgType MessageType, ch <-chan Message)
	Publish(ctx context.Context, msg Message) error
	Request(ctx context.Context, msg Message) (Message, error)
	Reply(ctx context.Context, ns MessageNamespace, msgType MessageType, h RequestHandler) error
}

func From

func From(container *service.Container) (Bus, error)

From retrieves the bus service in the given container

func Must

func Must(container *service.Container) Bus

Must retrieves the bus service in the given container or panic otherwise

type Message

type Message interface {
	MessageNamespace() MessageNamespace
	MessageType() MessageType
}

type MessageNamespace

type MessageNamespace string

func NewMessageNamespace

func NewMessageNamespace(namespaces ...MessageNamespace) MessageNamespace

type MessageType

type MessageType string

type RequestHandler

type RequestHandler func(msg Message) (Message, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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