messages

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0, Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToInterface

func ConvertToInterface[T msgType](msgs []*T, convertFunc func(m *T))

this is because Go doesn't support covariance on slices []*T -> []I does not work

Types

type Collector

type Collector[T msgType] struct {
	// contains filtered or unexported fields
}

Collector is a single message type collector

func NewCollector

func NewCollector[T msgType]() *Collector[T]

NewCollector creates a new message collector

func (*Collector[T]) AddMessage

func (c *Collector[T]) AddMessage(view *types.View, from []byte, message *T)

AddMessage adds a new message to the collector

func (*Collector[T]) DropMessages

func (c *Collector[T]) DropMessages(view *types.View)

DropMessages drops all messages from the collection if their view is less than the given view (earlier)

func (*Collector[T]) GetMessages

func (c *Collector[T]) GetMessages() []*T

GetMessages returns the currently present messages in the collector

func (*Collector[T]) Subscribe

func (c *Collector[T]) Subscribe() (<-chan func() []*T, func())

Subscribe creates a new collector subscription. Returns the channel for receiving messages, as well as the unsubscribe method

type MsgCallback

type MsgCallback[T msgType] func() []*T

MsgCallback is the callback that returns all given messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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