serialbus

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewListener

func NewListener(in <-chan []byte, d serial.TypeDeserializer, r serial.TypeRegistrar, errHandler any, handlers ...interface{}) (bus.Listener, error)

NewListener creates a Listener that reads from the in channel, deserializes to a value and passes the value to a ListenerMuxer.

func String

func String(in <-chan []byte) <-chan string

TODO: move this...somewhere String converts []byte to string on a channel.

Types

type MultiSender

type MultiSender struct {
	Chans map[string]chan<- []byte
	serial.TypeSerializer
}

MultiSender allows one message to be sent to multiple channels.

func NewMultiSender

func NewMultiSender(s serial.TypeSerializer) *MultiSender

func (*MultiSender) Add

func (ms *MultiSender) Add(key string, to interface{}) error

Add a chan<- []byte to the MultiSender and associate it with the key. If to is not of type chan<- []byte, an error is returned.

func (*MultiSender) AddCh

func (ms *MultiSender) AddCh(key string, ch chan<- []byte)

AddCh adds a chan<- []byte to the MultiSender and associate it with the key.

func (*MultiSender) Delete

func (ms *MultiSender) Delete(key string)

Delete a channel by key from the MultiSender.

func (*MultiSender) Send

func (ms *MultiSender) Send(msg interface{}, keys ...string) error

Send a message to the keys provided. If no keys are provided, the message will be sent to all channels.

type Receiver

type Receiver struct {
	In  <-chan []byte
	Out chan<- interface{}
	serial.TypeDeserializer
	serial.TypeRegistrar
	// contains filtered or unexported fields
}

Receiver takes serialized messages off a serial bus, deserializes them and places the deserialized objects on an interface channel.

func (*Receiver) RegisterType

func (r *Receiver) RegisterType(zeroValue interface{}) error

func (*Receiver) Run

func (r *Receiver) Run()

Run starts the Receiver. It must be running to receive messages.

func (*Receiver) SetErrorHandler

func (r *Receiver) SetErrorHandler(errHandler any) (err error)

SetErrorHandler to errHandler if ErrHandler is currently nil.

func (*Receiver) SetOut

func (r *Receiver) SetOut(out chan<- interface{})

SetOut sets the outgoing interface channel.

type Sender

type Sender struct {
	Chan chan<- []byte
	serial.TypeSerializer
}

Sender combines the logic of serializing an object and placing it on a channel

func (*Sender) Send

func (s *Sender) Send(msg interface{}) error

Send takes a message, serializes it and places it on a channel.

Jump to

Keyboard shortcuts

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