cluster

package
v0.0.0-...-dbfa1ae Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MPL-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClusterType is the TypeURL for Cluster discovery responses.
	ClusterType = typePrefix + "Cluster"

	// ListenerType is the TypeURL for Listener discovery responses.
	ListenerType = typePrefix + "Listener"
)

Variables

View Source
var ConsulBootstrapLimit = 10

ConsulBootstrapLimit is the maximum members to expect in a consul datacenter

View Source
var DiscoverBootstrapLimit = 10

DiscoverBootstrapLimit is the limit of attempts for the serf agent to try to join a cluster

Functions

func NewRequest

func NewRequest(key, value int) []byte

func TestJoin

func TestJoin(t *testing.T, s1 *Server, other ...*Server)

TestJoin joins two servers

func TrackLeader

func TrackLeader(b backend.SystemView, f func(ctx context.Context))

TrackLeader is a helper function that runs a callback when the node is set as the leadedr

Types

type Config

type Config struct {
	NodeName    string
	ServiceName string
	DataDir     string

	RPCAddr *net.TCPAddr

	RetryJoin     []string
	AdvertiseAddr *net.IPAddr

	SerfConfig   *serf.Config
	ConsulConfig *consul.Config

	RaftConfig        *raft.Config
	BootstrapExpected int32

	LogOutput io.Writer
	Backend   backend.Backend

	Telemetry *Telemetry
	Envoy     *EnvoyConfig
}

Config for the cluster server

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a cluster server config with default values

type EnvoyClient

type EnvoyClient struct {
	IngressPorts []Proxy
	EgressPorts  []Proxy
	// contains filtered or unexported fields
}

EnvoyClient is the control plane for envoy

func NewEnvoyClient

func NewEnvoyClient(logger hclog.Logger, addr net.IP, config *EnvoyConfig) (*EnvoyClient, error)

NewEnvoyClient creates a new envoy proxy

func (*EnvoyClient) Close

func (e *EnvoyClient) Close() error

Close stops the envoy proxy

func (*EnvoyClient) DeltaAggregatedResources

DeltaAggregatedResources implements envoydisc.AggregatedDiscoveryServiceServer

func (*EnvoyClient) EmitStats

func (e *EnvoyClient) EmitStats(period time.Duration, stopCh <-chan struct{})

EmitStats emits the stats of the envoy proxy

func (*EnvoyClient) IsEnabled

func (e *EnvoyClient) IsEnabled() bool

IsEnabled returns true if Envoy is enabled.

func (*EnvoyClient) RegisterEgressAddress

func (e *EnvoyClient) RegisterEgressAddress(name string, addr string, port int)

RegisterEgressAddress registers an egress entry for an address and a port

func (*EnvoyClient) RegisterIngressAddress

func (e *EnvoyClient) RegisterIngressAddress(name string, port int)

RegisterIngressAddress registers an egress entry for a port. Since we are building a proxy we expect the destiny address to bind to localhost.

func (*EnvoyClient) Resolve

func (e *EnvoyClient) Resolve(addr *net.TCPAddr) *net.TCPAddr

Resolve resolves a proxy address

func (*EnvoyClient) StreamAggregatedResources

StreamAggregatedResources implements envoydisc.AggregatedDiscoveryServiceServer

type EnvoyConfig

type EnvoyConfig struct {
	// Enabled is set to true to enable the envoy proxy
	Enabled bool `hcl:"enabled"`

	// AdminPort is the port for the envoy admin rest-api
	AdminPort int `hcl:"admin_port"`

	// GRPCPort is the port for the grpc control plane
	GRPCPort int `hcl:"grpc_port"`

	// Bianry is the path to the envoy binary
	Binary string `hcl:"binary"`

	// BaseID is used to differentiate different envoy instances on the same machine
	BaseID int `hcl:"base_id"`
}

EnvoyConfig is the envoy configuration

func DefaultEnvoyConfig

func DefaultEnvoyConfig() *EnvoyConfig

DefaultEnvoyConfig is the default envoy configuration

func (*EnvoyConfig) IsEnabled

func (e *EnvoyConfig) IsEnabled() bool

IsEnabled returns true if Envoy is enabled.

type Proxy

type Proxy struct {
	Label string // name of the proxy
	Addr  string // addr for an egress proxy
	Value int    // the port envoy binds
	To    int    // the port the proxy forwards to
}

Proxy is a reference for a proxy in envoy.

type ProxyType

type ProxyType int

ProxyType is the type of proxy

const (
	// IngressProxy is an ingress proxy type
	IngressProxy ProxyType = iota

	// EgressProxy is an egress proxy type
	EgressProxy
)

func (ProxyType) String

func (p ProxyType) String() string

type RPCType

type RPCType byte

RPCType represents different types of rpc to be used

const (
	// RPCRaft is the Raft rpc type
	RPCRaft RPCType = 0x02
)

type RaftLayer

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

RaftLayer implements the raft.StreamLayer to handle the raft connections inside the rpc stream.

func NewRaftLayer

func NewRaftLayer(addr net.Addr) *RaftLayer

NewRaftLayer creates a new raft layer.

func (*RaftLayer) Accept

func (l *RaftLayer) Accept() (net.Conn, error)

Accept implements the raft.StreamLayer interface

func (*RaftLayer) Addr

func (l *RaftLayer) Addr() net.Addr

Addr implements the raft.StreamLayer interface

func (*RaftLayer) Close

func (l *RaftLayer) Close() error

Close implements the raft.StreamLayer interface

func (*RaftLayer) Dial

func (l *RaftLayer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)

Dial implements the raft.StreamLayer interface

func (*RaftLayer) Handoff

func (l *RaftLayer) Handoff(c net.Conn) error

Handoff implements the raft.StreamLayer interface

type Server

type Server struct {
	Config *Config

	// Serf
	Serf *serf.Serf

	EventCh chan serf.Event

	// Raft
	Raft        *raft.Raft
	LeaderChAux chan bool

	Agent *consul.Agent

	ReconcileChAux chan serf.Member

	InmemSink *metrics.InmemSink
	// contains filtered or unexported fields
}

Server is a cloud-cluster server which handles a serf, raft and a consul agent instances

func NewServer

func NewServer(config *Config, logger hclog.Logger) (*Server, error)

NewServer creates a new cloud-cluster server

func TestServer

func TestServer(t *testing.T) *Server

TestServer creates a test server

func (*Server) IsLeader

func (s *Server) IsLeader() bool

func (*Server) Join

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

func (*Server) Leader

func (s *Server) Leader() string

func (*Server) LeaderCh

func (s *Server) LeaderCh() chan bool

func (*Server) Leave

func (s *Server) Leave() error

func (*Server) Members

func (s *Server) Members() []serf.Member

func (*Server) Peers

func (s *Server) Peers() (reply []string)

func (*Server) RPC

func (s *Server) RPC(method string, args interface{}, reply interface{}) error

RPC makes a call to the local rpc server

func (*Server) RPCRemote

func (s *Server) RPCRemote(server string, method string, args interface{}, reply interface{}) error

RPCRemote is used to call another peer

func (*Server) ReconcileCh

func (s *Server) ReconcileCh() chan serf.Member

func (*Server) RegisterRPC

func (s *Server) RegisterRPC(rcvr interface{})

func (*Server) Resolve

func (s *Server) Resolve(addr *net.TCPAddr) *net.TCPAddr

func (*Server) Shutdown

func (s *Server) Shutdown() error

type SetRequest

type SetRequest struct {
	Key, Value int
}

type SimpleFSM

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

func (*SimpleFSM) Apply

func (f *SimpleFSM) Apply(l *raft.Log) interface{}

func (*SimpleFSM) Restore

func (f *SimpleFSM) Restore(io.ReadCloser) error

func (*SimpleFSM) Snapshot

func (f *SimpleFSM) Snapshot() (raft.FSMSnapshot, error)

func (*SimpleFSM) State

func (f *SimpleFSM) State() *State

type State

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

func (*State) Set

func (s *State) Set(key, value int)

type Status

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

Status is the endpoint to query for the status of the server

func (*Status) Leader

func (s *Status) Leader(args interface{}, reply *string) error

Leader returns the current leader of the cluster

func (*Status) Peers

func (s *Status) Peers(args interface{}, reply *[]string) error

Peers returns the list of servers of the raft cluster

func (*Status) Ping

func (s *Status) Ping(args struct{}, reply *struct{}) error

Ping checks for connectivity

type Telemetry

type Telemetry struct {
	// DataDogAddr is the address of the statds-datadog extension server
	DataDogAddr string `hcl:"datadog_address"`
}

Telemetry is the telemetry config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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