communication

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Heartbeat indicates a check up message between a follower and master server
	Heartbeat Action = "HEARTBEAT"
	// Started indicates a server has successfully started
	Started = "STARTED"
	// Stopped indicates a server has gone inactive
	Stopped = "STOPPED"
	// NotMaster should be emit by a server when their reign has ended as master
	NotMaster = "NOT_MASTER"
	// ElectionStarted indicates a server has gone into election processing
	ElectionStarted = "ELECTION_STARTED"
	// Elect indicates a decision by one server that its' leader has been declared
	Elect = "ELECT"
	// Elected indicates a server has been named the leader
	Elected = "ELECTED"
	// ElectionEnded is the signal that a server has stopped its' election algorithm
	ElectionEnded = "ELECTION_ENDED"
	// StartNewElection is used by some election algorithms to notify another server that
	// it should start its' election process
	StartNewElection = "START_NEW_ELECTION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v1.0.0

type Action string

Action describes possible interactions that can happen with the election cluster

type Control added in v1.0.0

type Control struct {
	Target      string `json:"target"`
	ActionType  Action `json:"action"`
	MessageType string `json:"type"`
}

Control contains information for an action concerning a single server

func NewControl added in v1.0.0

func NewControl(target string, action Action) Control

NewControl creates a new Control message

type Emitter

type Emitter struct {
	// contains filtered or unexported fields
}

Emitter is a specialized queue for messaging

func New

func New(bufferSize int) *Emitter

New creates an instance of an emitter

func (*Emitter) Read

func (e *Emitter) Read() interface{}

Read returns the oldest message in the emitter, will block if no message is available

func (*Emitter) Write

func (e *Emitter) Write(m interface{})

Write will add a new message to the emitter

type Event added in v1.0.0

type Event struct {
	From        string `json:"from"`
	To          string `json:"to"`
	ActionType  Action `json:"action"`
	MessageType string `json:"type"`
}

Event contains information for an action regarding two servers

func NewEvent added in v1.0.0

func NewEvent(from, to string, action Action) Event

NewEvent creates a new Event message

Jump to

Keyboard shortcuts

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