Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultIndexFunc(idx *MDBIndex, parts []string) string
- func DefaultIndexPrefixFunc(idx *MDBIndex, parts []string) string
- func GetPrivateIP() (net.IP, error)
- func NewFSM(logOutput io.Writer) (*consulFSM, error)
- type Catalog
- func (c *Catalog) Deregister(args *structs.DeregisterRequest, reply *struct{}) error
- func (c *Catalog) ListDatacenters(args *struct{}, reply *[]string) error
- func (c *Catalog) ListNodes(args *structs.DCSpecificRequest, reply *structs.IndexedNodes) error
- func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.IndexedServices) error
- func (c *Catalog) NodeServices(args *structs.NodeSpecificRequest, reply *structs.IndexedNodeServices) error
- func (c *Catalog) Register(args *structs.RegisterRequest, reply *struct{}) error
- func (c *Catalog) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.IndexedServiceNodes) error
- type Client
- func (c *Client) JoinLAN(addrs []string) (int, error)
- func (c *Client) LANMembers() []serf.Member
- func (c *Client) Leave() error
- func (c *Client) LocalMember() serf.Member
- func (c *Client) RPC(method string, args interface{}, reply interface{}) error
- func (c *Client) RemoveFailedNode(node string) error
- func (c *Client) Shutdown() error
- func (c *Client) Stats() map[string]map[string]string
- type Config
- type Conn
- type ConnPool
- type Health
- func (h *Health) ChecksInState(args *structs.ChecksInStateRequest, reply *structs.IndexedHealthChecks) error
- func (h *Health) NodeChecks(args *structs.NodeSpecificRequest, reply *structs.IndexedHealthChecks) error
- func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest, reply *structs.IndexedHealthChecks) error
- func (h *Health) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.IndexedCheckServiceNodes) error
- type IndexFunc
- type Interface
- type Internal
- type KVS
- func (k *KVS) Apply(args *structs.KVSRequest, reply *bool) error
- func (k *KVS) Get(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error
- func (k *KVS) List(args *structs.KeyRequest, reply *structs.IndexedDirEntries) error
- func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error
- type MDBIndex
- type MDBTable
- func (t *MDBTable) Delete(index string, parts ...string) (num int, err error)
- func (t *MDBTable) DeleteTxn(tx *MDBTxn, index string, parts ...string) (int, error)
- func (t *MDBTable) Get(index string, parts ...string) (uint64, []interface{}, error)
- func (t *MDBTable) GetTxn(tx *MDBTxn, index string, parts ...string) ([]interface{}, error)
- func (t *MDBTable) Init() error
- func (t *MDBTable) Insert(obj interface{}) error
- func (t *MDBTable) InsertTxn(tx *MDBTxn, obj interface{}) error
- func (t *MDBTable) LastIndex() (uint64, error)
- func (t *MDBTable) LastIndexTxn(tx *MDBTxn) (uint64, error)
- func (t *MDBTable) SetLastIndex(index uint64) error
- func (t *MDBTable) SetLastIndexTxn(tx *MDBTxn, index uint64) error
- func (t *MDBTable) SetMaxLastIndexTxn(tx *MDBTxn, index uint64) error
- func (t *MDBTable) StartTxn(readonly bool, mdbTxn *MDBTxn) (*MDBTxn, error)
- func (t *MDBTable) StreamTxn(stream chan<- interface{}, tx *MDBTxn, index string, parts ...string) error
- type MDBTables
- type MDBTxn
- type NotifyGroup
- type RPCType
- type RaftLayer
- type Server
- func (s *Server) IsLeader() bool
- func (s *Server) JoinLAN(addrs []string) (int, error)
- func (s *Server) JoinWAN(addrs []string) (int, error)
- func (s *Server) LANMembers() []serf.Member
- func (s *Server) Leave() error
- func (c *Server) LocalMember() serf.Member
- func (s *Server) RPC(method string, args interface{}, reply interface{}) error
- func (s *Server) RemoveFailedNode(node string) error
- func (s *Server) Shutdown() error
- func (s *Server) Stats() map[string]map[string]string
- func (s *Server) WANMembers() []serf.Member
- type Session
- func (s *Session) Apply(args *structs.SessionRequest, reply *string) error
- func (s *Session) Get(args *structs.SessionSpecificRequest, reply *structs.IndexedSessions) error
- func (s *Session) List(args *structs.DCSpecificRequest, reply *structs.IndexedSessions) error
- func (s *Session) NodeSessions(args *structs.NodeSpecificRequest, reply *structs.IndexedSessions) error
- type StateSnapshot
- func (s *StateSnapshot) Close() error
- func (s *StateSnapshot) KVSDump(stream chan<- interface{}) error
- func (s *StateSnapshot) LastIndex() uint64
- func (s *StateSnapshot) NodeChecks(node string) structs.HealthChecks
- func (s *StateSnapshot) NodeServices(name string) *structs.NodeServices
- func (s *StateSnapshot) Nodes() structs.Nodes
- func (s *StateSnapshot) SessionList() ([]*structs.Session, error)
- type StateStore
- func (s *StateStore) CheckServiceNodes(service string) (uint64, structs.CheckServiceNodes)
- func (s *StateStore) CheckServiceTagNodes(service, tag string) (uint64, structs.CheckServiceNodes)
- func (s *StateStore) ChecksInState(state string) (uint64, structs.HealthChecks)
- func (s *StateStore) Close() error
- func (s *StateStore) DeleteNode(index uint64, node string) error
- func (s *StateStore) DeleteNodeCheck(index uint64, node, id string) error
- func (s *StateStore) DeleteNodeService(index uint64, node, id string) error
- func (s *StateStore) EnsureCheck(index uint64, check *structs.HealthCheck) error
- func (s *StateStore) EnsureNode(index uint64, node structs.Node) error
- func (s *StateStore) EnsureService(index uint64, node string, ns *structs.NodeService) error
- func (s *StateStore) GetNode(name string) (uint64, bool, string)
- func (s *StateStore) KVSCheckAndSet(index uint64, d *structs.DirEntry) (bool, error)
- func (s *StateStore) KVSDelete(index uint64, key string) error
- func (s *StateStore) KVSDeleteTree(index uint64, prefix string) error
- func (s *StateStore) KVSGet(key string) (uint64, *structs.DirEntry, error)
- func (s *StateStore) KVSList(prefix string) (uint64, structs.DirEntries, error)
- func (s *StateStore) KVSListKeys(prefix, seperator string) (uint64, []string, error)
- func (s *StateStore) KVSLock(index uint64, d *structs.DirEntry) (bool, error)
- func (s *StateStore) KVSLockDelay(key string) time.Time
- func (s *StateStore) KVSRestore(d *structs.DirEntry) error
- func (s *StateStore) KVSSet(index uint64, d *structs.DirEntry) error
- func (s *StateStore) KVSUnlock(index uint64, d *structs.DirEntry) (bool, error)
- func (s *StateStore) NodeChecks(node string) (uint64, structs.HealthChecks)
- func (s *StateStore) NodeDump() (uint64, structs.NodeDump)
- func (s *StateStore) NodeInfo(node string) (uint64, structs.NodeDump)
- func (s *StateStore) NodeServices(name string) (uint64, *structs.NodeServices)
- func (s *StateStore) NodeSessions(node string) (uint64, []*structs.Session, error)
- func (s *StateStore) Nodes() (uint64, structs.Nodes)
- func (s *StateStore) QueryTables(q string) MDBTables
- func (s *StateStore) ServiceChecks(service string) (uint64, structs.HealthChecks)
- func (s *StateStore) ServiceNodes(service string) (uint64, structs.ServiceNodes)
- func (s *StateStore) ServiceTagNodes(service, tag string) (uint64, structs.ServiceNodes)
- func (s *StateStore) Services() (uint64, map[string][]string)
- func (s *StateStore) SessionCreate(index uint64, session *structs.Session) error
- func (s *StateStore) SessionDestroy(index uint64, id string) error
- func (s *StateStore) SessionGet(id string) (uint64, *structs.Session, error)
- func (s *StateStore) SessionList() (uint64, []*structs.Session, error)
- func (s *StateStore) SessionRestore(session *structs.Session) error
- func (s *StateStore) Snapshot() (*StateSnapshot, error)
- func (s *StateStore) Watch(tables MDBTables, notify chan struct{})
- type Status
- type StreamClient
Constants ¶
const ( DefaultDC = "dc1" DefaultLANSerfPort = 8301 DefaultWANSerfPort = 8302 )
const ( SerfCheckID = "serfHealth" SerfCheckName = "Serf Health Status" SerfCheckAliveOutput = "Agent alive and reachable" SerfCheckFailedOutput = "Agent not live or unreachable" ConsulServiceID = "consul" ConsulServiceName = "consul" )
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.
const ( // StatusReap is used to update the status of a node if we // are handling a EventMemberReap StatusReap = serf.MemberStatus(-1) )
Variables ¶
var (
DefaultRPCAddr = &net.TCPAddr{IP: net.ParseIP("0.0.0.0"), Port: 8300}
)
Functions ¶
func DefaultIndexFunc ¶
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 ¶
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 ¶
GetPrivateIP is used to return the first private IP address associated with an interface on the machine
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 ¶
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 ¶
NewClient is used to construct a new Consul client from the configuration, potentially returning an error
func (*Client) JoinLAN ¶
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 ¶
LANMembers is used to return the members of the LAN cluster
func (*Client) LocalMember ¶ added in v0.3.0
LocalMember is used to return the local node
func (*Client) RemoveFailedNode ¶
RemoveFailedNode is used to remove a failed node from the cluster
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
AppendCA opens and parses the CA file and adds the certificates to the provided CertPool.
func (*Config) CheckVersion ¶
CheckVersion is used to check if the ProtocolVersion is valid
func (*Config) IncomingTLSConfig ¶
IncomingTLSConfig generates a TLS configuration for incoming requests
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a pooled connection to a Consul server
type ConnPool ¶
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.
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 ¶
func (h *Health) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.IndexedCheckServiceNodes) error
ServiceNodes returns all the nodes registered as part of a service including health info
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 ¶
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 ¶
DeleteTxn is like Delete, but occurs in a specific transaction that can span multiple tables.
func (*MDBTable) Get ¶
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 ¶
GetTxn is like Get but it operates within a specific transaction. This can be used for read that span multiple tables
func (*MDBTable) InsertTxn ¶
Insert is used to insert or update an object within a given transaction
func (*MDBTable) LastIndexTxn ¶
LastIndexTxn is like LastIndex but it operates within a specific transaction.
func (*MDBTable) SetLastIndex ¶
SetLastIndex is used to set the last index that updated the table
func (*MDBTable) SetLastIndexTxn ¶
SetLastIndexTxn is used to set the last index within a transaction
func (*MDBTable) SetMaxLastIndexTxn ¶ added in v0.3.0
SetMaxLastIndexTxn is used to set the last index within a transaction if it exceeds the current maximum
type MDBTables ¶
type MDBTables []*MDBTable
MDBTables is used for when we have a collection of tables
func (MDBTables) LastIndexTxn ¶
LastIndexTxn is used to get the last transaction from all of the tables
type MDBTxn ¶
type MDBTxn struct {
// contains filtered or unexported fields
}
MDBTxn is used to wrap an underlying transaction
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 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 ¶
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 ¶
Accept is used to return connection which are dialed to be used with the Raft layer
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 ¶
NewServer is used to construct a new Consul server from the configuration, potentially returning an error
func (*Server) JoinLAN ¶
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 ¶
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 ¶
LANMembers is used to return the members of the LAN cluster
func (*Server) LocalMember ¶ added in v0.3.0
LocalMember is used to return the local node
func (*Server) RemoveFailedNode ¶
RemoveFailedNode is used to remove a failed node from the cluster
func (*Server) Stats ¶
Stats is used to return statistics for debugging and insight for various sub-systems
func (*Server) WANMembers ¶
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
func (s *Session) Get(args *structs.SessionSpecificRequest, reply *structs.IndexedSessions) error
Get is used to retrieve a single session
func (*Session) List ¶ added in v0.3.0
func (s *Session) List(args *structs.DCSpecificRequest, reply *structs.IndexedSessions) error
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 ¶
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) 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
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
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
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
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
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