rbc

package
v0.0.0-...-f83d8fb Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStopped       = errors.New("process stopped")
	ErrDataLength    = errors.New("data too long")
	ErrInvalidSender = errors.New("invalid sender")
)
View Source
var ErrInvalidType = errors.New("invalid message type")

Functions

func ValidMessageType

func ValidMessageType(v byte) bool

Types

type Message

type Message struct {
	Type MessageType
	Data []byte
}

func (*Message) MarshalBinary

func (m *Message) MarshalBinary() ([]byte, error)

func (*Message) UnmarshalBinary

func (m *Message) UnmarshalBinary(data []byte) error

type MessageError

type MessageError struct {
	SenderID string
	Type     MessageType
	Str      string
}

func (*MessageError) Error

func (e *MessageError) Error() string

type MessageType

type MessageType byte
const (
	Propose MessageType = iota
	Echo
	Ready
)

func (MessageType) String

func (t MessageType) String() string

type OutMessage

type OutMessage struct {
	Receiver string
	Payload  *Message
}

type Predicate

type Predicate func([]byte) bool

type RBC

type RBC struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(conf *config.Config, dealer string, maxLength int, pred Predicate) *RBC

func (*RBC) Close

func (r *RBC) Close() error

func (*RBC) Handle

func (r *RBC) Handle(sender string, msg *Message) error

func (*RBC) Input

func (r *RBC) Input(data []byte)

func (*RBC) Messages

func (r *RBC) Messages() <-chan *OutMessage

func (*RBC) Output

func (r *RBC) Output() <-chan []byte

Jump to

Keyboard shortcuts

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