buffer

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsString added in v0.4.0

func ContainsString(a []string, x string) bool

ContainsString tells whether a contains x.

func MissingStrings added in v0.4.0

func MissingStrings(a []string, b []string) []string

MissingStrings returns the disjunction between given slices: a - b.

Types

type Buffer added in v0.4.0

type Buffer struct {
	Elements []Element   `json:"elements"`
	Len      int         `json:"len"`
	Mux      *sync.Mutex `json:"mux"`
}

Buffer is the buffer with messages.

func NewBuffer added in v0.4.0

func NewBuffer(size int) *Buffer

NewBuffer creates new buffer.

func (*Buffer) Add added in v0.4.0

func (buf *Buffer) Add(el Element) error

Add adds the given element in buffer.

func (*Buffer) Digest added in v0.4.0

func (buf *Buffer) Digest() []string

Digest returns a slice with elements ids.

func (*Buffer) ElementsFromIDs added in v0.4.0

func (buf *Buffer) ElementsFromIDs(digest []string) []Element

ElementsFromIDs returns a slice with elements from given IDs list.

func (*Buffer) IncrementGossipCount added in v0.4.0

func (buf *Buffer) IncrementGossipCount()

IncrementGossipCount increments gossip count for each elements from buffer.

func (*Buffer) Length added in v0.4.0

func (buf *Buffer) Length() int

Length returns number of elements in buffer.

func (*Buffer) Messages added in v0.4.0

func (buf *Buffer) Messages() []interface{}

Messages returns a slice with messages for each element in buffer.

type Element added in v0.4.0

type Element struct {
	ID           string      `json:"id"`
	Timestamp    time.Time   `json:"timestamp"`
	Msg          interface{} `json:"msg"`
	CallbackType string      `json:"callbackType"`
	GossipCount  int64       `json:"gossipCount"` // number of rounds since the element is in buffer
}

Element is an element from messages buffer.

func NewElement added in v0.4.0

func NewElement(msg interface{}, cbType string) (Element, error)

NewElement creates new buffer element with given message and callback type.

Jump to

Keyboard shortcuts

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