server

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

Documentation

Index

Constants

View Source
const (
	// Running is the state that server will be set to when online
	Running = iota
	// Stopped is the state that server will be set to when offline
	Stopped = iota
)

Variables

This section is empty.

Functions

func GenerateUniqueID

func GenerateUniqueID() string

GenerateUniqueID returns a cluster compliant unique server id

Types

type Base

type Base struct {
	Master         string
	ID             string
	State          int
	ElectionLock   sync.Mutex
	Emitter        *communication.Emitter
	HeartbeatPause time.Duration
}

Base is a single entity

func New

func New(e *communication.Emitter, heartbeatPause time.Duration) *Base

New will create a cluster with the specified number of servers

func (*Base) GetID

func (s *Base) GetID() string

GetID returns the server id

func (*Base) IsUp

func (s *Base) IsUp() bool

IsUp returns whether or not the current server is running

func (*Base) MarshalJSON added in v1.0.0

func (s *Base) MarshalJSON() ([]byte, error)

MarshalJSON retrieves the target server as a json string

func (*Base) Restart

func (s *Base) Restart()

Restart the provided server

func (*Base) SetMaster

func (s *Base) SetMaster(masterID string) bool

SetMaster assigns the specified master to the calling server's master variable

func (*Base) Stop

func (s *Base) Stop()

Stop the provided server

func (*Base) String added in v1.0.0

func (s *Base) String() string

String displays the server information in a readable format

type Process

type Process interface {
	Boot()
	Restart()
	Stop()
	String() string
	GetID() string
	SetMaster(string) bool
	IsUp() bool
	MarshalJSON() ([]byte, error)
}

Process describes all classes that can be run as a mock server

type Setup

type Setup interface {
	Setup(int, *communication.Emitter, time.Duration) map[string]Process
}

Setup describes all classes that can be used to construct an array of servers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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