election

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

README

election

PkgGoDev Go Report Card Release codecov

Overview

election is a project that simulates various leader election algorithms in distributed systems. This project's primary use is for educational purposes.

Visual implementation located here: https://recover-e.herokuapp.com

To install
go get github.com/LostLaser/election
Algorithms currently implemented

Contributing

Want to improve the project? Open an issue and list what you would like to change/add so we can discuss it.

Retrieving the source
git clone https://github.com/LostLaser/election
cd election
go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	ID string
	// contains filtered or unexported fields
}

Cluster is a linked collection of servers

func New

func New(processSetup server.Setup, serverCount int, heartbeatPause time.Duration, logger *zap.Logger) *Cluster

New will create a cluster with the specified number of servers

func (Cluster) MarshalJSON added in v1.0.0

func (c Cluster) MarshalJSON() ([]byte, error)

MarshalJSON retrieves the target cluster as a json string

func (Cluster) Purge

func (c Cluster) Purge()

Purge will stop all of the linked servers but not clear their references

func (Cluster) ReadEvent

func (c Cluster) ReadEvent() interface{}

ReadEvent will retrieve a single event log of the servers' actions

func (Cluster) ServerIds

func (c Cluster) ServerIds() []string

ServerIds returns all server ids in the cluster

func (Cluster) StartServer

func (c Cluster) StartServer(id string) error

StartServer starts the server with the specified id in the cluster

func (Cluster) StopServer

func (c Cluster) StopServer(id string) error

StopServer stops the server with the specified id in the cluster

func (Cluster) String added in v1.0.0

func (c Cluster) String() string

String gets the string representation of the target cluster

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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