consul

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2014 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDC          = "dc1"
	DefaultLANSerfPort = 8301
	DefaultWANSerfPort = 8302
)
View Source
const (
	SerfCheckID           = "serfHealth"
	SerfCheckName         = "Serf Health Status"
	SerfCheckAliveOutput  = "Agent alive and reachable"
	SerfCheckFailedOutput = "Agent not live or unreachable"
	ConsulServiceID       = "consul"
	ConsulServiceName     = "consul"
)
View Source
const (
	ProtocolVersionMin uint8 = 1
	ProtocolVersionMax       = 2
)

These are the protocol versions that Consul can _understand_. These are Consul-level protocol versions, that are used to configure the Serf protocol versions.

View Source
const (
	// StatusReap is used to update the status of a node if we
	// are handling a EventMemberReap
	StatusReap = serf.MemberStatus(-1)
)

Variables

View Source
var (
	DefaultRPCAddr = &net.TCPAddr{IP: net.ParseIP("0.0.0.0"), Port: 8300}
)

Functions

func DefaultIndexFunc

func DefaultIndexFunc(idx *MDBIndex, parts []string) string

DefaultIndexFunc is used if no IdxFunc is provided. It joins the columns using '||' which is reasonably unlikely to occur. We also prefix with a byte to ensure we never have a zero length key

func DefaultIndexPrefixFunc

func DefaultIndexPrefixFunc(idx *MDBIndex, parts []string) string

DefaultIndexPrefixFunc can be used with DefaultIndexFunc to scan for index prefix values. This should only be used as part of a virtual index.

func GetPrivateIP

func GetPrivateIP() (net.IP, error)

GetPrivateIP is used to return the first private IP address associated with an interface on the machine

func NewFSM

func NewFSM(logOutput io.Writer) (*consulFSM, error)

NewFSM is used to construct a new FSM with a blank state

Types

type Catalog

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

Catalog endpoint is used to manipulate the service catalog

func (*Catalog) Deregister

func (c *Catalog) Deregister(args *structs.DeregisterRequest, reply *struct{}) error

Deregister is used to remove a service registration for a given node.

func (*Catalog) ListDatacenters

func (c *Catalog) ListDatacenters(args *struct{}, reply *[]string) error

ListDatacenters is used to query for the list of known datacenters

func (*Catalog) ListNodes

func (c *Catalog) ListNodes(args *structs.DCSpecificRequest, reply *structs.IndexedNodes) error

ListNodes is used to query the nodes in a DC

func (*Catalog) ListServices

func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.IndexedServices) error

ListServices is used to query the services in a DC

func (*Catalog) NodeServices

func (c *Catalog) NodeServices(args *structs.NodeSpecificRequest, reply *structs.IndexedNodeServices) error

NodeServices returns all the services registered as part of a node

func (*Catalog) Register

func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error

Register is used register that a node is providing a given service.

func (*Catalog) ServiceNodes

func (c *Catalog) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.IndexedServiceNodes) error

ServiceNodes returns all the nodes registered as part of a service

type Client

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

Client is Consul client which uses RPC to communicate with the services for service discovery, health checking, and DC forwarding.

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient is used to construct a new Consul client from the configuration, potentially returning an error

func (*Client) JoinLAN

func (c *Client) JoinLAN(addrs []string) (int, error)

JoinLAN is used to have Consul client join the inner-DC pool The target address should be another node inside the DC listening on the Serf LAN address

func (*Client) LANMembers

func (c *Client) LANMembers() []serf.Member

LANMembers is used to return the members of the LAN cluster

func (*Client) Leave

func (c *Client) Leave() error

Leave is used to prepare for a graceful shutdown

func (*Client) LocalMember added in v0.3.0

func (c *Client) LocalMember() serf.Member

LocalMember is used to return the local node

func (*Client) RPC

func (c *Client) RPC(method string, args interface{}, reply interface{}) error

RPC is used to forward an RPC call to a consul server, or fail if no servers

func (*Client) RemoveFailedNode

func (c *Client) RemoveFailedNode(node string) error

RemoveFailedNode is used to remove a failed node from the cluster

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown is used to shutdown the client

func (*Client) Stats

func (c *Client) Stats() map[string]map[string]string

Stats is used to return statistics for debugging and insight for various sub-systems

type Config

type Config struct {
	// Bootstrap mode is used to bring up the first Consul server.
	// It is required so that it can elect a leader without any
	// other nodes being present
	Bootstrap bool

	// BootstrapExpect mode is used to automatically bring up a collection of
	// Consul servers. This can be used to automatically bring up a collection
	// of nodes.
	BootstrapExpect int

	// Datacenter is the datacenter this Consul server represents
	Datacenter string

	// DataDir is the directory to store our state in
	DataDir string

	// Node name is the name we use to advertise. Defaults to hostname.
	NodeName string

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

	// RPCAddr is the RPC address used by Consul. This should be reachable
	// by the WAN and LAN
	RPCAddr *net.TCPAddr

	// RPCAdvertise is the address that is advertised to other nodes for
	// the RPC endpoint. This can differ from the RPC address, if for example
	// the RPCAddr is unspecified "0.0.0.0:8300", but this address must be
	// reachable
	RPCAdvertise *net.TCPAddr

	// SerfLANConfig is the configuration for the intra-dc serf
	SerfLANConfig *serf.Config

	// SerfWANConfig is the configuration for the cross-dc serf
	SerfWANConfig *serf.Config

	// ReconcileInterval controls how often we reconcile the strongly
	// consistent store with the Serf info. This is used to handle nodes
	// that are force removed, as well as intermittent unavailability during
	// leader election.
	ReconcileInterval time.Duration

	// LogOutput is the location to write logs to. If this is not set,
	// logs will go to stderr.
	LogOutput io.Writer

	// ProtocolVersion is the protocol version to speak. This must be between
	// ProtocolVersionMin and ProtocolVersionMax.
	ProtocolVersion uint8

	// VerifyIncoming is used to verify the authenticity of incoming connections.
	// This means that TCP requests are forbidden, only allowing for TLS. TLS connections
	// must match a provided certificate authority. This can be used to force client auth.
	VerifyIncoming bool

	// VerifyOutgoing is used to verify the authenticity of outgoing connections.
	// This means that TLS requests are used, and TCP requests are not made. TLS connections
	// must match a provided certificate authority. This is used to verify authenticity of
	// server nodes.
	VerifyOutgoing bool

	// CAFile is a path to a certificate authority file. This is used with VerifyIncoming
	// or VerifyOutgoing to verify the TLS connection.
	CAFile string

	// CertFile is used to provide a TLS certificate that is used for serving TLS connections.
	// Must be provided to serve TLS connections.
	CertFile string

	// KeyFile is used to provide a TLS key that is used for serving TLS connections.
	// Must be provided to serve TLS connections.
	KeyFile string

	// ServerName is used with the TLS certificate to ensure the name we
	// provide matches the certificate
	ServerName string

	// RejoinAfterLeave controls our interaction with Serf.
	// When set to false (default), a leave causes a Consul to not rejoin
	// the cluster until an explicit join is received. If this is set to
	// true, we ignore the leave, and rejoin the cluster on start.
	RejoinAfterLeave bool

	// Build is a string that is gossiped around, and can be used to help
	// operators track which versions are actively deployed
	Build string

	// ServerUp callback can be used to trigger a notification that
	// a Consul server is now up and known about.
	ServerUp func()
}

Config is used to configure the server

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig is used to return a sane default configuration

func (*Config) AppendCA added in v0.3.0

func (c *Config) AppendCA(pool *x509.CertPool) error

AppendCA opens and parses the CA file and adds the certificates to the provided CertPool.

func (*Config) CheckVersion

func (c *Config) CheckVersion() error

CheckVersion is used to check if the ProtocolVersion is valid

func (*Config) IncomingTLSConfig

func (c *Config) IncomingTLSConfig() (*tls.Config, error)

IncomingTLSConfig generates a TLS configuration for incoming requests

func (*Config) KeyPair

func (c *Config) KeyPair() (*tls.Certificate, error)

KeyPair is used to open and parse a certificate and key file

func (*Config) OutgoingTLSConfig

func (c *Config) OutgoingTLSConfig() (*tls.Config, error)

OutgoingTLSConfig generates a TLS configuration for outgoing requests. It will return a nil config if this configuration should not use TLS for outgoing connections.

type Conn

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

Conn is a pooled connection to a Consul server

func (*Conn) Close

func (c *Conn) Close() error

type ConnPool

type ConnPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ConnPool is used to maintain a connection pool to other Consul servers. This is used to reduce the latency of RPC requests between servers. It is only used to pool connections in the rpcConsul mode. Raft connections are pooled seperately.

func NewPool

func NewPool(logOutput io.Writer, maxTime time.Duration, maxStreams int, tlsConfig *tls.Config) *ConnPool

NewPool is used to make a new connection pool Maintain at most one connection per host, for up to maxTime. Set maxTime to 0 to disable reaping. maxStreams is used to control the number of idle streams allowed. If TLS settings are provided outgoing connections use TLS.

func (*ConnPool) RPC

func (p *ConnPool) RPC(addr net.Addr, version int, method string, args interface{}, reply interface{}) error

RPC is used to make an RPC call to a remote host

func (*ConnPool) Shutdown

func (p *ConnPool) Shutdown() error

Shutdown is used to close the connection pool

type Health

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

Health endpoint is used to query the health information

func (*Health) ChecksInState

func (h *Health) ChecksInState(args *structs.ChecksInStateRequest,
	reply *structs.IndexedHealthChecks) error

ChecksInState is used to get all the checks in a given state

func (*Health) NodeChecks

func (h *Health) NodeChecks(args *structs.NodeSpecificRequest,
	reply *structs.IndexedHealthChecks) error

NodeChecks is used to get all the checks for a node

func (*Health) ServiceChecks

func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest,
	reply *structs.IndexedHealthChecks) error

ServiceChecks is used to get all the checks for a service

func (*Health) ServiceNodes

ServiceNodes returns all the nodes registered as part of a service including health info

type IndexFunc

type IndexFunc func(*MDBIndex, []string) string

type Interface

type Interface interface {
	RPC(method string, args interface{}, reply interface{}) error
	LANMembers() []serf.Member
	LocalMember() serf.Member
}

Interface is used to provide either a Client or Server, both of which can be used to perform certain common Consul methods

type Internal added in v0.2.0

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

Internal endpoint is used to query the miscellaneous info that does not necessarily fit into the other systems. It is also used to hold undocumented APIs that users should not rely on.

func (*Internal) NodeDump added in v0.2.0

func (m *Internal) NodeDump(args *structs.DCSpecificRequest,
	reply *structs.IndexedNodeDump) error

ChecksInState is used to get all the checks in a given state

func (*Internal) NodeInfo added in v0.2.0

func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
	reply *structs.IndexedNodeDump) error

ChecksInState is used to get all the checks in a given state

type KVS

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

KVS endpoint is used to manipulate the Key-Value store

func (*KVS) Apply

func (k *KVS) Apply(args *structs.KVSRequest, reply *bool) error

Apply is used to apply a KVS request to the data store. This should only be used for operations that modify the data

func (*KVS) Get

func (k *KVS) Get(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error

Get is used to lookup a single key

func (*KVS) List

func (k *KVS) List(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error

List is used to list all keys with a given prefix

func (*KVS) ListKeys added in v0.2.0

func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error

ListKeys is used to list all keys with a given prefix to a seperator

type MDBIndex

type MDBIndex struct {
	AllowBlank bool      // Can fields be blank
	Unique     bool      // Controls if values are unique
	Fields     []string  // Fields are used to build the index
	IdxFunc    IndexFunc // Can be used to provide custom indexing
	Virtual    bool      // Virtual index does not exist, but can be used for queries
	RealIndex  string    // Virtual indexes use a RealIndex for iteration
	// contains filtered or unexported fields
}

An Index is named, and uses a series of column values to map to the row-id containing the table

type MDBTable

type MDBTable struct {
	Env     *mdb.Env
	Name    string // This is the name of the table, must be unique
	Indexes map[string]*MDBIndex
	Encoder func(interface{}) []byte
	Decoder func([]byte) interface{}
	// contains filtered or unexported fields
}

An MDB table is a logical representation of a table, which is a generic row store. It provides a simple mechanism to store rows using a row id, while maintaining any number of secondary indexes.

func (*MDBTable) Delete

func (t *MDBTable) Delete(index string, parts ...string) (num int, err error)

Delete is used to delete one or more rows. An index an appropriate fields are specified. The fields can be a prefix of the index. Returns the rows deleted or an error.

func (*MDBTable) DeleteTxn

func (t *MDBTable) DeleteTxn(tx *MDBTxn, index string, parts ...string) (int, error)

DeleteTxn is like Delete, but occurs in a specific transaction that can span multiple tables.

func (*MDBTable) Get

func (t *MDBTable) Get(index string, parts ...string) (uint64, []interface{}, error)

Get is used to lookup one or more rows. An index an appropriate fields are specified. The fields can be a prefix of the index.

func (*MDBTable) GetTxn

func (t *MDBTable) GetTxn(tx *MDBTxn, index string, parts ...string) ([]interface{}, error)

GetTxn is like Get but it operates within a specific transaction. This can be used for read that span multiple tables

func (*MDBTable) Init

func (t *MDBTable) Init() error

Init is used to initialize the MDBTable and ensure it's ready

func (*MDBTable) Insert

func (t *MDBTable) Insert(obj interface{}) error

Insert is used to insert or update an object

func (*MDBTable) InsertTxn

func (t *MDBTable) InsertTxn(tx *MDBTxn, obj interface{}) error

Insert is used to insert or update an object within a given transaction

func (*MDBTable) LastIndex

func (t *MDBTable) LastIndex() (uint64, error)

LastIndex is get the last index that updated the table

func (*MDBTable) LastIndexTxn

func (t *MDBTable) LastIndexTxn(tx *MDBTxn) (uint64, error)

LastIndexTxn is like LastIndex but it operates within a specific transaction.

func (*MDBTable) SetLastIndex

func (t *MDBTable) SetLastIndex(index uint64) error

SetLastIndex is used to set the last index that updated the table

func (*MDBTable) SetLastIndexTxn

func (t *MDBTable) SetLastIndexTxn(tx *MDBTxn, index uint64) error

SetLastIndexTxn is used to set the last index within a transaction

func (*MDBTable) SetMaxLastIndexTxn added in v0.3.0

func (t *MDBTable) SetMaxLastIndexTxn(tx *MDBTxn, index uint64) error

SetMaxLastIndexTxn is used to set the last index within a transaction if it exceeds the current maximum

func (*MDBTable) StartTxn

func (t *MDBTable) StartTxn(readonly bool, mdbTxn *MDBTxn) (*MDBTxn, error)

startTxn is used to start a transaction

func (*MDBTable) StreamTxn

func (t *MDBTable) StreamTxn(stream chan<- interface{}, tx *MDBTxn, index string, parts ...string) error

StreamTxn is like GetTxn but it streams the results over a channel. This can be used if the expected data set is very large. The stream is always closed on return.

type MDBTables

type MDBTables []*MDBTable

MDBTables is used for when we have a collection of tables

func (MDBTables) LastIndexTxn

func (t MDBTables) LastIndexTxn(tx *MDBTxn) (uint64, error)

LastIndexTxn is used to get the last transaction from all of the tables

func (MDBTables) StartTxn

func (t MDBTables) StartTxn(readonly bool) (*MDBTxn, error)

StartTxn is used to create a transaction that spans a list of tables

type MDBTxn

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

MDBTxn is used to wrap an underlying transaction

func (*MDBTxn) Abort

func (t *MDBTxn) Abort()

Abort is used to close the transaction

func (*MDBTxn) Commit

func (t *MDBTxn) Commit() error

Commit is used to commit a transaction

func (*MDBTxn) Defer added in v0.3.0

func (t *MDBTxn) Defer(f func())

Defer is used to defer a function call until a successful commit

type NotifyGroup

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

NotifyGroup is used to allow a simple notification mechanism. Channels can be marked as waiting, and when notify is invoked, all the waiting channels get a message and are cleared from the notify list.

func (*NotifyGroup) Notify

func (n *NotifyGroup) Notify()

Notify will do a non-blocking send to all waiting channels, and clear the notify list

func (*NotifyGroup) Wait

func (n *NotifyGroup) Wait(ch chan struct{})

Wait adds a channel to the notify group

func (*NotifyGroup) WaitCh

func (n *NotifyGroup) WaitCh() chan struct{}

WaitCh allocates a channel that is subscribed to notifications

type RPCType

type RPCType byte

type RaftLayer

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

RaftLayer implements the raft.StreamLayer interface, so that we can use a single RPC layer for Raft and Consul

func NewRaftLayer

func NewRaftLayer(addr net.Addr, tlsConfig *tls.Config) *RaftLayer

NewRaftLayer is used to initialize a new RaftLayer which can be used as a StreamLayer for Raft. If a tlsConfig is provided, then the connection will use TLS.

func (*RaftLayer) Accept

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

Accept is used to return connection which are dialed to be used with the Raft layer

func (*RaftLayer) Addr

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

Addr is used to return the address of the listener

func (*RaftLayer) Close

func (l *RaftLayer) Close() error

Close is used to stop listening for Raft connections

func (*RaftLayer) Dial

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

Dial is used to create a new outgoing connection

func (*RaftLayer) Handoff

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

Handoff is used to hand off a connection to the RaftLayer. This allows it to be Accept()'ed

type Server

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

Server is Consul server which manages the service discovery, health checking, DC forwarding, Raft, and multiple Serf pools.

func NewServer

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

NewServer is used to construct a new Consul server from the configuration, potentially returning an error

func (*Server) IsLeader

func (s *Server) IsLeader() bool

IsLeader checks if this server is the cluster leader

func (*Server) JoinLAN

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

JoinLAN is used to have Consul join the inner-DC pool The target address should be another node inside the DC listening on the Serf LAN address

func (*Server) JoinWAN

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

JoinWAN is used to have Consul join the cross-WAN Consul ring The target address should be another node listening on the Serf WAN address

func (*Server) LANMembers

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

LANMembers is used to return the members of the LAN cluster

func (*Server) Leave

func (s *Server) Leave() error

Leave is used to prepare for a graceful shutdown of the server

func (*Server) LocalMember added in v0.3.0

func (c *Server) LocalMember() serf.Member

LocalMember is used to return the local node

func (*Server) RPC

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

RPC is used to make a local RPC call

func (*Server) RemoveFailedNode

func (s *Server) RemoveFailedNode(node string) error

RemoveFailedNode is used to remove a failed node from the cluster

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown is used to shutdown the server

func (*Server) Stats

func (s *Server) Stats() map[string]map[string]string

Stats is used to return statistics for debugging and insight for various sub-systems

func (*Server) WANMembers

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

WANMembers is used to return the members of the LAN cluster

type Session added in v0.3.0

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

Session endpoint is used to manipulate sessions for KV

func (*Session) Apply added in v0.3.0

func (s *Session) Apply(args *structs.SessionRequest, reply *string) error

Apply is used to apply a modifying request to the data store. This should only be used for operations that modify the data

func (*Session) Get added in v0.3.0

Get is used to retrieve a single session

func (*Session) List added in v0.3.0

List is used to list all the active sessions

func (*Session) NodeSessions added in v0.3.0

func (s *Session) NodeSessions(args *structs.NodeSpecificRequest,
	reply *structs.IndexedSessions) error

NodeSessions is used to get all the sessions for a particular node

type StateSnapshot

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

StateSnapshot is used to provide a point-in-time snapshot It works by starting a readonly transaction against all tables.

func (*StateSnapshot) Close

func (s *StateSnapshot) Close() error

Close is used to abort the transaction and allow for cleanup

func (*StateSnapshot) KVSDump

func (s *StateSnapshot) KVSDump(stream chan<- interface{}) error

KVSDump is used to list all KV entries. It takes a channel and streams back *struct.DirEntry objects. This will block and should be invoked in a goroutine.

func (*StateSnapshot) LastIndex

func (s *StateSnapshot) LastIndex() uint64

LastIndex returns the last index that affects the snapshotted data

func (*StateSnapshot) NodeChecks

func (s *StateSnapshot) NodeChecks(node string) structs.HealthChecks

NodeChecks is used to return all the checks of a given node

func (*StateSnapshot) NodeServices

func (s *StateSnapshot) NodeServices(name string) *structs.NodeServices

NodeServices is used to return all the services of a given node

func (*StateSnapshot) Nodes

func (s *StateSnapshot) Nodes() structs.Nodes

Nodes returns all the known nodes, the slice alternates between the node name and address

func (*StateSnapshot) SessionList added in v0.3.0

func (s *StateSnapshot) SessionList() ([]*structs.Session, error)

SessionList is used to list all the open sessions

type StateStore

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

The StateStore is responsible for maintaining all the Consul state. It is manipulated by the FSM which maintains consistency through the use of Raft. The goals of the StateStore are to provide high concurrency for read operations without blocking writes, and to provide write availability in the face of reads. The current implementation uses the Lightning Memory-Mapped Database (MDB). This gives us Multi-Version Concurrency Control for "free"

func NewStateStore

func NewStateStore(logOutput io.Writer) (*StateStore, error)

NewStateStore is used to create a new state store

func (*StateStore) CheckServiceNodes

func (s *StateStore) CheckServiceNodes(service string) (uint64, structs.CheckServiceNodes)

CheckServiceNodes returns the nodes associated with a given service, along with any associated check

func (*StateStore) CheckServiceTagNodes

func (s *StateStore) CheckServiceTagNodes(service, tag string) (uint64, structs.CheckServiceNodes)

CheckServiceNodes returns the nodes associated with a given service, along with any associated checks

func (*StateStore) ChecksInState

func (s *StateStore) ChecksInState(state string) (uint64, structs.HealthChecks)

CheckInState is used to get all the checks for a service in a given state

func (*StateStore) Close

func (s *StateStore) Close() error

Close is used to safely shutdown the state store

func (*StateStore) DeleteNode

func (s *StateStore) DeleteNode(index uint64, node string) error

DeleteNode is used to delete a node and all it's services

func (*StateStore) DeleteNodeCheck

func (s *StateStore) DeleteNodeCheck(index uint64, node, id string) error

DeleteNodeCheck is used to delete a node health check

func (*StateStore) DeleteNodeService

func (s *StateStore) DeleteNodeService(index uint64, node, id string) error

DeleteNodeService is used to delete a node service

func (*StateStore) EnsureCheck

func (s *StateStore) EnsureCheck(index uint64, check *structs.HealthCheck) error

EnsureCheck is used to create a check or updates it's state

func (*StateStore) EnsureNode

func (s *StateStore) EnsureNode(index uint64, node structs.Node) error

EnsureNode is used to ensure a given node exists, with the provided address

func (*StateStore) EnsureService

func (s *StateStore) EnsureService(index uint64, node string, ns *structs.NodeService) error

EnsureService is used to ensure a given node exposes a service

func (*StateStore) GetNode

func (s *StateStore) GetNode(name string) (uint64, bool, string)

GetNode returns all the address of the known and if it was found

func (*StateStore) KVSCheckAndSet

func (s *StateStore) KVSCheckAndSet(index uint64, d *structs.DirEntry) (bool, error)

KVSCheckAndSet is used to perform an atomic check-and-set

func (*StateStore) KVSDelete

func (s *StateStore) KVSDelete(index uint64, key string) error

KVSDelete is used to delete a KVS entry

func (*StateStore) KVSDeleteTree

func (s *StateStore) KVSDeleteTree(index uint64, prefix string) error

KVSDeleteTree is used to delete all keys with a given prefix

func (*StateStore) KVSGet

func (s *StateStore) KVSGet(key string) (uint64, *structs.DirEntry, error)

KVSGet is used to get a KV entry

func (*StateStore) KVSList

func (s *StateStore) KVSList(prefix string) (uint64, structs.DirEntries, error)

KVSList is used to list all KV entries with a prefix

func (*StateStore) KVSListKeys added in v0.2.0

func (s *StateStore) KVSListKeys(prefix, seperator string) (uint64, []string, error)

KVSListKeys is used to list keys with a prefix, and up to a given seperator

func (*StateStore) KVSLock added in v0.3.0

func (s *StateStore) KVSLock(index uint64, d *structs.DirEntry) (bool, error)

KVSLock works like KVSSet but only writes if the lock can be acquired

func (*StateStore) KVSLockDelay added in v0.3.0

func (s *StateStore) KVSLockDelay(key string) time.Time

KVSLockDelay returns the expiration time of a key lock delay. A key may have a lock delay if it was unlocked due to a session invalidation instead of a graceful unlock. This must be checked on the leader node, and not in KVSLock due to the variability of clocks.

func (*StateStore) KVSRestore

func (s *StateStore) KVSRestore(d *structs.DirEntry) error

KVSRestore is used to restore a DirEntry. It should only be used when doing a restore, otherwise KVSSet should be used.

func (*StateStore) KVSSet

func (s *StateStore) KVSSet(index uint64, d *structs.DirEntry) error

KVSSet is used to create or update a KV entry

func (*StateStore) KVSUnlock added in v0.3.0

func (s *StateStore) KVSUnlock(index uint64, d *structs.DirEntry) (bool, error)

KVSUnlock works like KVSSet but only writes if the lock can be unlocked

func (*StateStore) NodeChecks

func (s *StateStore) NodeChecks(node string) (uint64, structs.HealthChecks)

NodeChecks is used to get all the checks for a node

func (*StateStore) NodeDump added in v0.2.0

func (s *StateStore) NodeDump() (uint64, structs.NodeDump)

NodeDump is used to generate the NodeInfo for all nodes. This is very expensive, and should generally be avoided for programatic access.

func (*StateStore) NodeInfo added in v0.2.0

func (s *StateStore) NodeInfo(node string) (uint64, structs.NodeDump)

NodeInfo is used to generate the full info about a node.

func (*StateStore) NodeServices

func (s *StateStore) NodeServices(name string) (uint64, *structs.NodeServices)

NodeServices is used to return all the services of a given node

func (*StateStore) NodeSessions added in v0.3.0

func (s *StateStore) NodeSessions(node string) (uint64, []*structs.Session, error)

NodeSessions is used to list all the open sessions for a node

func (*StateStore) Nodes

func (s *StateStore) Nodes() (uint64, structs.Nodes)

GetNodes returns all the known nodes, the slice alternates between the node name and address

func (*StateStore) QueryTables

func (s *StateStore) QueryTables(q string) MDBTables

QueryTables returns the Tables that are queried for a given query

func (*StateStore) ServiceChecks

func (s *StateStore) ServiceChecks(service string) (uint64, structs.HealthChecks)

ServiceChecks is used to get all the checks for a service

func (*StateStore) ServiceNodes

func (s *StateStore) ServiceNodes(service string) (uint64, structs.ServiceNodes)

ServiceNodes returns the nodes associated with a given service

func (*StateStore) ServiceTagNodes

func (s *StateStore) ServiceTagNodes(service, tag string) (uint64, structs.ServiceNodes)

ServiceTagNodes returns the nodes associated with a given service matching a tag

func (*StateStore) Services

func (s *StateStore) Services() (uint64, map[string][]string)

Services is used to return all the services with a list of associated tags

func (*StateStore) SessionCreate added in v0.3.0

func (s *StateStore) SessionCreate(index uint64, session *structs.Session) error

SessionCreate is used to create a new session. The ID will be populated on a successful return

func (*StateStore) SessionDestroy added in v0.3.0

func (s *StateStore) SessionDestroy(index uint64, id string) error

SessionDelete is used to destroy a session.

func (*StateStore) SessionGet added in v0.3.0

func (s *StateStore) SessionGet(id string) (uint64, *structs.Session, error)

SessionGet is used to get a session entry

func (*StateStore) SessionList added in v0.3.0

func (s *StateStore) SessionList() (uint64, []*structs.Session, error)

SessionList is used to list all the open sessions

func (*StateStore) SessionRestore added in v0.3.0

func (s *StateStore) SessionRestore(session *structs.Session) error

SessionRestore is used to restore a session. It should only be used when doing a restore, otherwise SessionCreate should be used.

func (*StateStore) Snapshot

func (s *StateStore) Snapshot() (*StateSnapshot, error)

Snapshot is used to create a point in time snapshot

func (*StateStore) Watch

func (s *StateStore) Watch(tables MDBTables, notify chan struct{})

Watch is used to subscribe a channel to a set of MDBTables

type Status

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

Status endpoint is used to check on server status

func (*Status) Leader

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

Leader is used to get the address of the leader

func (*Status) Peers

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

Peers is used to get all the Raft peers

func (*Status) Ping

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

Ping is used to just check for connectivity

type StreamClient added in v0.3.0

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

streamClient is used to wrap a stream with an RPC client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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