Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultIndexFunc(idx *MDBIndex, parts []string) string
- func DefaultIndexPrefixFunc(idx *MDBIndex, parts []string) string
- func FilterDirEnt(acl acl.ACL, ent structs.DirEntries) structs.DirEntries
- func FilterEntries(f Filter) int
- func FilterKeys(acl acl.ACL, keys []string) []string
- func GetPrivateIP() (net.IP, error)
- func NewFSM(gc *TombstoneGC, path string, logOutput io.Writer) (*consulFSM, error)
- func ToLowerList(l []string) []string
- type ACL
- func (a *ACL) Apply(args *structs.ACLRequest, reply *string) error
- func (a *ACL) Get(args *structs.ACLSpecificRequest, reply *structs.IndexedACLs) error
- func (a *ACL) GetPolicy(args *structs.ACLPolicyRequest, reply *structs.ACLPolicy) error
- func (a *ACL) List(args *structs.DCSpecificRequest, reply *structs.IndexedACLs) 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) Encrypted() bool
- func (c *Client) JoinLAN(addrs []string) (int, error)
- func (c *Client) KeyManagerLAN() *serf.KeyManager
- 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
- func (c *Client) UserEvent(name string, payload []byte) error
- type Config
- type Conn
- type ConnPool
- type Filter
- 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
- func (m *Internal) EventFire(args *structs.EventFireRequest, reply *structs.EventFireResponse) error
- func (m *Internal) KeyringOperation(args *structs.KeyringRequest, reply *structs.KeyringResponses) error
- func (m *Internal) NodeDump(args *structs.DCSpecificRequest, reply *structs.IndexedNodeDump) error
- func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest, reply *structs.IndexedNodeDump) error
- 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) GetTxnLimit(tx *MDBTxn, limit int, 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) Encrypted() bool
- func (s *Server) IsLeader() bool
- func (s *Server) JoinLAN(addrs []string) (int, error)
- func (s *Server) JoinWAN(addrs []string) (int, error)
- func (s *Server) KeyManagerLAN() *serf.KeyManager
- func (s *Server) KeyManagerWAN() *serf.KeyManager
- 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) UserEvent(name string, payload []byte) error
- 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
- func (s *Session) Renew(args *structs.SessionSpecificRequest, reply *structs.IndexedSessions) error
- type StateSnapshot
- func (s *StateSnapshot) ACLList() ([]*structs.ACL, error)
- 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)
- func (s *StateSnapshot) TombstoneDump(stream chan<- interface{}) error
- type StateStore
- func (s *StateStore) ACLDelete(index uint64, id string) error
- func (s *StateStore) ACLGet(id string) (uint64, *structs.ACL, error)
- func (s *StateStore) ACLList() (uint64, []*structs.ACL, error)
- func (s *StateStore) ACLRestore(acl *structs.ACL) error
- func (s *StateStore) ACLSet(index uint64, acl *structs.ACL) error
- 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) EnsureRegistration(index uint64, req *structs.RegisterRequest) 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) KVSDeleteCheckAndSet(index uint64, key string, casIndex uint64) (bool, 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, 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) ReapTombstones(index uint64) error
- 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) TombstoneRestore(d *structs.DirEntry) error
- func (s *StateStore) Watch(tables MDBTables, notify chan struct{})
- func (s *StateStore) WatchKV(prefix string, notify chan struct{})
- type Status
- type StreamClient
- type TombstoneGC
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 FilterDirEnt ¶ added in v0.4.0
func FilterDirEnt(acl acl.ACL, ent structs.DirEntries) structs.DirEntries
FilterDirEnt is used to filter a list of directory entries by applying an ACL policy
func FilterEntries ¶ added in v0.4.0
FilterEntries is used to do an inplace filter of a slice. This has cost proportional to the list length.
func FilterKeys ¶ added in v0.4.0
FilterKeys is used to filter a list of keys by applying an ACL policy
func GetPrivateIP ¶
GetPrivateIP is used to return the first private IP address associated with an interface on the machine
func NewFSM ¶
func NewFSM(gc *TombstoneGC, path string, logOutput io.Writer) (*consulFSM, error)
NewFSMPath is used to construct a new FSM with a blank state
func ToLowerList ¶ added in v0.4.0
Types ¶
type ACL ¶ added in v0.4.0
type ACL struct {
// contains filtered or unexported fields
}
ACL endpoint is used to manipulate ACLs
func (*ACL) Apply ¶ added in v0.4.0
func (a *ACL) Apply(args *structs.ACLRequest, 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 (*ACL) Get ¶ added in v0.4.0
func (a *ACL) Get(args *structs.ACLSpecificRequest, reply *structs.IndexedACLs) error
Get is used to retrieve a single ACL
func (*ACL) GetPolicy ¶ added in v0.4.0
GetPolicy is used to retrieve a compiled policy object with a TTL. Does not support a blocking query.
func (*ACL) List ¶ added in v0.4.0
func (a *ACL) List(args *structs.DCSpecificRequest, reply *structs.IndexedACLs) error
List is used to list all the ACLs
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) KeyManagerLAN ¶ added in v0.5.0
func (c *Client) KeyManagerLAN() *serf.KeyManager
KeyManagerLAN returns the LAN Serf keyring manager
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 // ACLToken is the default token to use when making a request. // If not provided, the anonymous token is used. This enables // backwards compatibility as well. ACLToken string // ACLMasterToken is used to bootstrap the ACL system. It should be specified // on the servers in the ACLDatacenter. When the leader comes online, it ensures // that the Master token is available. This provides the initial token. ACLMasterToken string // ACLDatacenter provides the authoritative datacenter for ACL // tokens. If not provided, ACL verification is disabled. ACLDatacenter string // ACLTTL controls the time-to-live of cached ACL policies. // It can be set to zero to disable caching, but this adds // a substantial cost. ACLTTL time.Duration // ACLDefaultPolicy is used to control the ACL interaction when // there is no defined policy. This can be "allow" which means // ACLs are used to black-list, or "deny" which means ACLs are // white-lists. ACLDefaultPolicy string // ACLDownPolicy controls the behavior of ACLs if the ACLDatacenter // cannot be contacted. It can be either "deny" to deny all requests, // or "extend-cache" which ignores the ACLCacheInterval and uses // cached policies. If a policy is not in the cache, it acts like deny. // "allow" can be used to allow all requests. This is not recommended. ACLDownPolicy string // TombstoneTTL is used to control how long KV tombstones are retained. // This provides a window of time where the X-Consul-Index is monotonic. // Outside this window, the index may not be monotonic. This is a result // of a few trade offs: // 1) The index is defined by the data view and not globally. This is a // performance optimization that prevents any write from incrementing the // index for all data views. // 2) Tombstones are not kept indefinitely, since otherwise storage required // is also monotonic. This prevents deletes from reducing the disk space // used. // In theory, neither of these are intrinsic limitations, however for the // purposes of building a practical system, they are reaonable trade offs. // // It is also possible to set this to an incredibly long time, thereby // simulating infinite retention. This is not recommended however. // TombstoneTTL time.Duration // TombstoneTTLGranularity is used to control how granular the timers are // for the Tombstone GC. This is used to batch the GC of many keys together // to reduce overhead. It is unlikely a user would ever need to tune this. TombstoneTTLGranularity time.Duration // ServerUp callback can be used to trigger a notification that // a Consul server is now up and known about. ServerUp func() // UserEventHandler callback can be used to handle incoming // user events. This function should not block. UserEventHandler func(serf.UserEvent) }
Config is used to configure the server
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is used to return a sane default configuration
func (*Config) CheckVersion ¶
CheckVersion is used to check if the ProtocolVersion is valid
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 separately.
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 Filter ¶ added in v0.4.0
Filter interfae is used with FilterEntries to do an in-place filter of a slice.
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) EventFire ¶ added in v0.4.0
func (m *Internal) EventFire(args *structs.EventFireRequest, reply *structs.EventFireResponse) error
EventFire is a bit of an odd endpoint, but it allows for a cross-DC RPC call to fire an event. The primary use case is to enable user events being triggered in a remote DC.
func (*Internal) KeyringOperation ¶ added in v0.5.0
func (m *Internal) KeyringOperation( args *structs.KeyringRequest, reply *structs.KeyringResponses) error
KeyringOperation will query the WAN and LAN gossip keyrings of all nodes.
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 CaseInsensitive bool // Controls if values are case-insensitive // 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) GetTxnLimit ¶ added in v0.5.0
func (t *MDBTable) GetTxnLimit(tx *MDBTxn, limit int, index string, parts ...string) ([]interface{}, error)
GetTxnLimit is like GetTxn limits the maximum number of rows it will return
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) KeyManagerLAN ¶ added in v0.5.0
func (s *Server) KeyManagerLAN() *serf.KeyManager
KeyManagerLAN returns the LAN Serf keyring manager
func (*Server) KeyManagerWAN ¶ added in v0.5.0
func (s *Server) KeyManagerWAN() *serf.KeyManager
KeyManagerWAN returns the WAN Serf keyring manager
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) UserEvent ¶ added in v0.4.0
UserEvent is used to fire an event via the Serf layer on the LAN
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
func (*Session) Renew ¶ added in v0.5.0
func (s *Session) Renew(args *structs.SessionSpecificRequest, reply *structs.IndexedSessions) error
Renew is used to renew the TTL on a single session
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) ACLList ¶ added in v0.4.0
func (s *StateSnapshot) ACLList() ([]*structs.ACL, error)
ACLList is used to list all of the ACLs
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
func (*StateSnapshot) TombstoneDump ¶ added in v0.5.0
func (s *StateSnapshot) TombstoneDump(stream chan<- interface{}) error
TombstoneDump is used to dump all tombstone entries. It takes a channel and streams back *struct.DirEntry objects. This will block and should be invoked in a goroutine.
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(gc *TombstoneGC, logOutput io.Writer) (*StateStore, error)
NewStateStore is used to create a new state store
func NewStateStorePath ¶ added in v0.4.1
func NewStateStorePath(gc *TombstoneGC, path string, logOutput io.Writer) (*StateStore, error)
NewStateStorePath is used to create a new state store at a given path The path is cleared on closing.
func (*StateStore) ACLDelete ¶ added in v0.4.0
func (s *StateStore) ACLDelete(index uint64, id string) error
ACLDelete is used to remove an ACL
func (*StateStore) ACLList ¶ added in v0.4.0
func (s *StateStore) ACLList() (uint64, []*structs.ACL, error)
ACLList is used to list all the acls
func (*StateStore) ACLRestore ¶ added in v0.4.0
func (s *StateStore) ACLRestore(acl *structs.ACL) error
ACLRestore is used to restore an ACL. It should only be used when doing a restore, otherwise ACLSet should be used.
func (*StateStore) ACLSet ¶ added in v0.4.0
func (s *StateStore) ACLSet(index uint64, acl *structs.ACL) error
ACLSet is used to create or update an ACL entry
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) EnsureRegistration ¶ added in v0.4.0
func (s *StateStore) EnsureRegistration(index uint64, req *structs.RegisterRequest) error
EnsureRegistration is used to make sure a node, service, and check registration is performed within a single transaction to avoid race conditions on state updates.
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) KVSDeleteCheckAndSet ¶ added in v0.5.0
KVSDeleteCheckAndSet is used to perform an atomic delete check-and-set
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, 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) ReapTombstones ¶ added in v0.5.0
func (s *StateStore) ReapTombstones(index uint64) error
ReapTombstones is used to delete all the tombstones with a ModifyTime less than or equal to the given index. This is used to prevent unbounded storage growth of the tombstones.
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
SessionDestroy 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) TombstoneRestore ¶ added in v0.5.0
func (s *StateStore) TombstoneRestore(d *structs.DirEntry) error
TombstoneRestore is used to restore a tombstone. It should only be used when doing a restore.
func (*StateStore) Watch ¶
func (s *StateStore) Watch(tables MDBTables, notify chan struct{})
Watch is used to subscribe a channel to a set of MDBTables
func (*StateStore) WatchKV ¶ added in v0.5.0
func (s *StateStore) WatchKV(prefix string, notify chan struct{})
WatchKV is used to subscribe a channel to changes in KV data
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
type TombstoneGC ¶ added in v0.5.0
type TombstoneGC struct {
// contains filtered or unexported fields
}
TombstoneGC is used to track creation of tombstones so that they can be garbage collected after their TTL expires. The tombstones allow queries to provide monotonic index values within the TTL window. The GC is used to prevent monotonic growth in storage usage. This is a trade off between the length of the TTL and the storage overhead.
In practice, this is required to fix the issue of delete visibility. When data is deleted from the KV store, the "latest" row can go backwards if the newest row is removed. The tombstones provide a way to ensure time doesn't move backwards within some interval.
func NewTombstoneGC ¶ added in v0.5.0
func NewTombstoneGC(ttl, granularity time.Duration) (*TombstoneGC, error)
NewTombstoneGC is used to construct a new TombstoneGC given a TTL for tombstones and a tracking granularity. Longer TTLs ensure correct behavior for more time, but use more storage. A shorter granularity increases the number of Raft transactions and reduce how far past the TTL we perform GC.
func (*TombstoneGC) ExpireCh ¶ added in v0.5.0
func (t *TombstoneGC) ExpireCh() <-chan uint64
ExpireCh is used to return a channel that streams the next index that should be expired
func (*TombstoneGC) Hint ¶ added in v0.5.0
func (t *TombstoneGC) Hint(index uint64)
Hint is used to indicate that keys at the given index have been deleted, and that their GC should be scheduled.
func (*TombstoneGC) PendingExpiration ¶ added in v0.5.0
func (t *TombstoneGC) PendingExpiration() bool
PendingExpiration is used to check if any expirations are pending
func (*TombstoneGC) SetEnabled ¶ added in v0.5.0
func (t *TombstoneGC) SetEnabled(enabled bool)
SetEnabled is used to control if the tombstone GC is enabled. Should only be enabled by the leader node.
Source Files ¶
- acl.go
- acl_endpoint.go
- catalog_endpoint.go
- client.go
- config.go
- filter.go
- fsm.go
- health_endpoint.go
- internal_endpoint.go
- kvs_endpoint.go
- leader.go
- mdb_table.go
- merge.go
- notify.go
- pool.go
- raft_rpc.go
- rpc.go
- serf.go
- server.go
- session_endpoint.go
- session_ttl.go
- state_store.go
- status_endpoint.go
- tombstone_gc.go
- util.go