bus

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Listener

type Listener interface {
	ListenerSwitcher
	RegisterHandlers(handler ...any) error
	RegisterType(zeroValue any) error
}

Listener combines a Receiver and a ListenerSwitcher to take in data from a bus, convert the data to an interface value and multiplex them out to the correct handlers.

type ListenerMethodsRegistrar

type ListenerMethodsRegistrar struct {
	handler.MethodsRegistrar
}

func (ListenerMethodsRegistrar) Register

func (lmr ListenerMethodsRegistrar) Register(l Listener, handlerType any) error

RegisterHandlerType is a bit of reflection magic. Calls RegisterMuxHandlerType on the underlying ListenerMuxer and registers the returned types with the underlying Receiver.

type ListenerSwitcher

type ListenerSwitcher interface {
	handler.Switcher
	Run()
	SetIn(<-chan any)
	SetErrorHandler(any) error
}

ListenerSwitcher takes values off an interface channel and multiplexes them out to the correct handlers for the given type.

type MultiSender

type MultiSender interface {
	Send(msg any, ids ...string) error
	Add(key string, to any) error
	Delete(key string)
}

MultiSender will send a message to multiple busses at once. This can reduce duplication of work. For instance, if a message needs to be serialized, it will only be serialized once.

type Receiver

type Receiver interface {
	Run()
	RegisterType(zeroValue any) error
	SetOut(out chan<- any)
	SetErrorHandler(any) error
}

Receiver receives data from a bus translates it to a value and retransmits the value on an interface bus. For example, it may receive data as a byte slice, deserialize to a value and retransmit the value.

type Sender

type Sender interface {
	Send(msg any) error
}

Sender handles the operations to place a message on a bus. For instance, it may contain the logic to serialize the message.

Directories

Path Synopsis
Package iobus converts an io.Reader or io.Writer to a chan []byte.
Package iobus converts an io.Reader or io.Writer to a chan []byte.

Jump to

Keyboard shortcuts

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