server

package
v0.0.0-...-3d85bc3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	Storage        storage.Storage
	StateMachine   storage.StateMachine
	SecretsManager rpc.SecretsManager
	PeerSecretNum  uint32
	ServerId       uint32
	ServerAddr     string
}

type Server

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

Raft represents a single participant in a Raft cluster.

func New

func New(params Params) (*Server, error)

NewServer constructs a new Server.

func (*Server) Addr

func (svr *Server) Addr() string

Addr returns this Server's UDP address.

func (*Server) Bootstrap

func (svr *Server) Bootstrap(clusterUUID string)

func (*Server) Configuration

func (svr *Server) Configuration() *pb.Configuration

Configuration returns the Server's active Configuration.

func (*Server) ForceElection

func (svr *Server) ForceElection()

ForceElection forces a new leadership election, nominating this Server as the proposed leader.

func (*Server) Id

func (svr *Server) Id() uint32

Id returns the identifier for this Server.

func (*Server) IsLeader

func (svr *Server) IsLeader() bool

IsLeader returns true if this Server is *probably* the leader. (The information may be stale.)

func (*Server) OnGainLeadership

func (svr *Server) OnGainLeadership(fn func(*Server))

OnGainLeadership sets the callback which, if non-nil, will be executed when this Server becomes the leader.

The previous leader may believe it is still the leader for up to 150 ticks.

func (*Server) OnLonely

func (svr *Server) OnLonely(fn func(*Server))

func (*Server) OnLoseLeadership

func (svr *Server) OnLoseLeadership(fn func(*Server))

OnLoseLeadership sets the callback which, if non-nil, will be executed when this Server is no longer the leader.

func (*Server) OnNotLonely

func (svr *Server) OnNotLonely(fn func(*Server))

func (*Server) Start

func (svr *Server) Start() error

Start launches this Server.

func (*Server) Stop

func (svr *Server) Stop() error

Stop halts this Server and releases resources.

func (*Server) String

func (svr *Server) String() string

String returns a dense but human-readable summary of this Server's state.

func (*Server) Tick

func (svr *Server) Tick()

Jump to

Keyboard shortcuts

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