message

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InMemoryBusMaximumInFlightMessage = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Emit(ctx context.Context, message Message) error
	Read(ctx context.Context) (<-chan Message, context.CancelFunc)
}

type Handler

type Handler func(ctx context.Context, message Message) (Message, error)

type InMemoryBus

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

func NewInMemoryBus

func NewInMemoryBus() *InMemoryBus

func (*InMemoryBus) Emit

func (i *InMemoryBus) Emit(ctx context.Context, message Message) error

func (*InMemoryBus) Read

func (i *InMemoryBus) Read(ctx context.Context) (<-chan Message, context.CancelFunc)

type Message

type Message struct {
	ID      xid.ID
	Kind    string
	Payload any
}

func New

func New(kind string, payload any) Message

func (Message) CreatedAt

func (m Message) CreatedAt() time.Time

func (Message) Node

func (m Message) Node() []byte

type NoOpBus

type NoOpBus struct{}

func NewNoopBus

func NewNoopBus() *NoOpBus

func (NoOpBus) Emit

func (NoOpBus) Emit(_ context.Context, _ Message) error

func (NoOpBus) Read

func (NoOpBus) Read(_ context.Context) (<-chan Message, context.CancelFunc)

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Registry) Register

func (r *Registry) Register(kind string, handler Handler) uint32

func (*Registry) Unregister

func (r *Registry) Unregister(kind string, slot uint32) error

type RegistrySlot

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

func (*RegistrySlot) Register

func (r *RegistrySlot) Register(handler Handler) uint32

func (*RegistrySlot) Unregister

func (r *RegistrySlot) Unregister(slot uint32) error

Jump to

Keyboard shortcuts

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