openstate

package
v0.0.0-...-c736ba3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRaftPort = 7050
	DefaultSerfPort = 4648
	DefaultHTTPPort = 8080
)

Variables

This section is empty.

Functions

func DefaultHTTPAddr

func DefaultHTTPAddr() *net.TCPAddr

func DefaultRaftAddr

func DefaultRaftAddr() *net.TCPAddr

func DefaultSerfAddr

func DefaultSerfAddr() *net.TCPAddr

func NewFSM

func NewFSM(config *openstateFSMConfig) (*openstateFSM, error)

NewFSM returns a FSM given a config.

Types

type Config

type Config struct {
	// BootstrapExpect is used to determine how many peers to expect.
	//
	// The BootstrapExpect can be of any of the following values:
	//  1: Server will form a single node cluster and become a leader immediately
	//  N, larger than 1: Server will wait until it's connected to N servers
	//      before attempting leadership and forming the cluster.  No Raft Log operation
	//      will succeed until then.
	//
	// Defaults to 1
	BootstrapExpect int

	// DevMode indicates if the OpenState server should run in development mode.
	// This disables the log, stable, and snapshot stores, and uses a simple
	// in-memory store instead.
	//
	// Defaults to 'false'
	DevMode bool

	// DataDirectory is a path to directory where OpenState stores state related
	// objects; primarily snapshots, logs, and the stable store.
	//
	// Defaults to $HOME/.openstate/
	DataDirectory string

	// HTTPAdvertise is the advertised address of the HTTP endpoints.
	//
	// Defaults to "127.0.0.1:8080"
	HTTPAdvertise *net.TCPAddr

	// Logger is the logger used by the OpenState server, raft, and serf.
	Logger log.InterceptLogger

	// LogOutput is the location to write logs to.
	//
	// Defaults to stdout.
	LogOutput io.Writer

	// NodeID is the UUID of the server
	//
	// Defaults to a random UUID
	NodeID string

	// NodeName is the advertised name of the server.
	//
	// Defaults to the node's hostname.
	NodeName string

	// HACK / TODO / REMOVE ME
	//
	// Peers are the initial list of peer serf addresses. This option is a hack
	// to bypass the need for service discovery (TODO). This list only needs to
	// contain ONE valid peer; the gossip layer will propogate the peer across all
	// nodes.
	//
	// Defaults to an empty list
	Peers []string

	// RaftAdvertise is the advertised address of the Raft node. This should
	// differ from the SerfAdvertise.
	//
	// Defaults to "0.0.0.0:5479"
	RaftAdvertise *net.TCPAddr

	// RaftConfig is the configuration used for Raft.
	RaftConfig *raft.Config

	// RaftTimeout is applied to any network traffic for raft.
	//
	// Defaults to 10s.
	RaftTimeout time.Duration

	// SerfAdvertise is the advertised address of the Serf node. This should
	// differ from the RaftAdvertise.
	//
	// Defaults to "0.0.0.0:7479"
	SerfAdvertise *net.TCPAddr

	// SerfConfig is the configuration used for Serf.
	SerfConfig *serf.Config
}

Config is the comprehensive list of Server options.

func DefaultConfig

func DefaultConfig() *Config

type HTTPServer

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

HTTPServer wraps Server and exposes it over an HTTP interface.

func NewHTTPServer

func NewHTTPServer(s *Server, c *Config) (*HTTPServer, error)

newHTTPServer returns a new HTTPServ object.

type Server

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

Server is the OpenState server which manages tasks etc.

func NewServer

func NewServer(c *Config) (*Server, error)

func (*Server) IsLeader

func (s *Server) IsLeader() bool

IsLeader returns true if the server's raft node is the leader, otherwise false

func (*Server) Join

func (s *Server) Join(addrs []string) (int, error)

Join join's the server to the OpenSteate gossip ring. The target address(es) should be another node listening on the Serf address.

func (*Server) Leave

func (s *Server) Leave() error

Leave removes the server from the OpenState gossip ring.

func (*Server) Run

func (s *Server) Run()

Keep-alive hack

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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