Documentation ¶
Overview ¶
The snapshot endpoint is a special non-RPC endpoint that supports streaming for taking and restoring snapshots for disaster recovery. This gets wired directly into Consul's stream handler, and a new TCP connection is made for each request.
This also includes a SnapshotRPC() function, which acts as a lightweight client that knows the details of the stream protocol.
Index ¶
- Constants
- Variables
- func CanServersUnderstandProtocol(members []serf.Member, version uint8) (bool, error)
- func FilterDirEnt(acl acl.ACL, ent structs.DirEntries) structs.DirEntries
- func FilterEntries(f Filter) int
- func FilterKeys(acl acl.ACL, keys []string) []string
- func FilterTxnResults(acl acl.ACL, results structs.TxnResults) structs.TxnResults
- func GetPrivateIP() (net.IP, error)
- func GetPublicIPv6() (net.IP, error)
- func NewFSM(gc *state.TombstoneGC, logOutput io.Writer) (*consulFSM, error)
- func SnapshotRPC(pool *ConnPool, dc string, addr net.Addr, args *structs.SnapshotRequest, ...) (io.ReadCloser, error)
- 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
- func (a *ACL) ReplicationStatus(args *structs.DCSpecificRequest, reply *structs.ACLReplicationStatus) 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) GetCoordinate() (*coordinate.Coordinate, error)
- 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) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, ...) error
- func (c *Client) Stats() map[string]map[string]string
- type Config
- type Conn
- type ConnPool
- type Coordinate
- type Filter
- type HalfCloser
- 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 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 Operator
- type PreparedQuery
- func (p *PreparedQuery) Apply(args *structs.PreparedQueryRequest, reply *string) (err error)
- func (p *PreparedQuery) Execute(args *structs.PreparedQueryExecuteRequest, ...) error
- func (p *PreparedQuery) ExecuteRemote(args *structs.PreparedQueryExecuteRemoteRequest, ...) error
- func (p *PreparedQuery) Explain(args *structs.PreparedQueryExecuteRequest, ...) error
- func (p *PreparedQuery) Get(args *structs.PreparedQuerySpecificRequest, ...) error
- func (p *PreparedQuery) List(args *structs.DCSpecificRequest, reply *structs.IndexedPreparedQueries) error
- type RPCType
- type RaftLayer
- type Server
- func (s *Server) Encrypted() bool
- func (s *Server) GetLANCoordinate() (*coordinate.Coordinate, error)
- func (s *Server) GetWANCoordinate() (*coordinate.Coordinate, error)
- func (s *Server) InjectEndpoint(endpoint interface{}) error
- func (s *Server) IsACLReplicationEnabled() 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) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, ...) 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
- func (s *Session) Renew(args *structs.SessionSpecificRequest, reply *structs.IndexedSessions) error
- type SnapshotReplyFn
- type Status
- type StreamClient
- type Txn
Constants ¶
const ( DefaultDC = "dc1" DefaultLANSerfPort = 8301 DefaultWANSerfPort = 8302 // DefaultRaftMultiplier is used as a baseline Raft configuration that // will be reliable on a very basic server. See docs/guides/performance.html // for information on how this value was obtained. DefaultRaftMultiplier uint = 5 // MaxRaftMultiplier is a fairly arbitrary upper bound that limits the // amount of performance detuning that's possible. MaxRaftMultiplier uint = 10 )
const ( SerfCheckID types.CheckID = "serfHealth" SerfCheckName = "Serf Health Status" SerfCheckAliveOutput = "Agent alive and reachable" SerfCheckFailedOutput = "Agent not live or unreachable" ConsulServiceID = "consul" ConsulServiceName = "consul" )
const ( ProtocolVersionMin uint8 = 2 // Version 3 added support for network coordinates but we kept the // default protocol version at 2 to ease the transition to this new // feature. A Consul agent speaking version 2 of the protocol will // attempt to send its coordinates to a server who understands version // 3 or greater. ProtocolVersion2Compatible = 2 ProtocolVersionMax = 3 )
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}
)
var ( // ErrQueryNotFound is returned if the query lookup failed. ErrQueryNotFound = errors.New("Query not found") )
Functions ¶
func CanServersUnderstandProtocol ¶ added in v0.6.0
CanServersUnderstandProtocol checks to see if all the servers in the given list understand the given protocol version. If there are no servers in the list then this will return false.
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 FilterTxnResults ¶ added in v0.7.0
func FilterTxnResults(acl acl.ACL, results structs.TxnResults) structs.TxnResults
FilterTxnResults is used to filter a list of transaction results 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 GetPublicIPv6 ¶ added in v0.7.0
GetPublicIPv6 is used to return the first public IP address associated with an interface on the machine
func NewFSM ¶
func NewFSM(gc *state.TombstoneGC, logOutput io.Writer) (*consulFSM, error)
NewFSM is used to construct a new FSM with a blank state
func SnapshotRPC ¶ added in v0.7.1
func SnapshotRPC(pool *ConnPool, dc string, addr net.Addr, args *structs.SnapshotRequest, in io.Reader, reply *structs.SnapshotResponse) (io.ReadCloser, error)
SnapshotRPC is a streaming client function for performing a snapshot RPC request to a remote server. It will create a fresh connection for each request, send the request header, and then stream in any data from the reader (for a restore). It will then parse the received response header, and if there's no error will return an io.ReadCloser (that you must close) with the streaming output (for a snapshot). If the reply contains an error, this will always return an error as well, so you don't need to check the error inside the filled-in reply.
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
func (*ACL) ReplicationStatus ¶ added in v0.7.0
func (a *ACL) ReplicationStatus(args *structs.DCSpecificRequest, reply *structs.ACLReplicationStatus) error
ReplicationStatus is used to retrieve the current ACL replication status.
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) GetCoordinate ¶ added in v0.6.0
func (c *Client) GetCoordinate() (*coordinate.Coordinate, error)
GetCoordinate returns the network coordinate of the current node, as maintained by Serf.
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
func (*Client) SnapshotRPC ¶ added in v0.7.1
func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn SnapshotReplyFn) error
SnapshotRPC sends the snapshot request to one of the servers, reading from the streaming input and writing to the streaming output depending on the operation.
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 // DevMode is used to enable a development server mode. DevMode bool // NodeID is a unique identifier for this node across space and time. NodeID types.NodeID // Node name is the name we use to advertise. Defaults to hostname. NodeName string // Domain is the DNS domain for the records. Defaults to "consul." Domain 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 // VerifyServerHostname is used to enable hostname verification of servers. This // ensures that the certificate presented is valid for server.<datacenter>.<domain>. // This prevents a compromised client from being restarted as a server, and then // intercepting request traffic as well as being added as a raft peer. This should be // enabled by default with VerifyOutgoing, but for legacy reasons we cannot break // existing clients. VerifyServerHostname 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 // TLSMinVersion is used to set the minimum TLS version used for TLS connections. TLSMinVersion 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 // ACLAgentToken is the default token used to make requests for the agent // itself, such as for registering itself with the catalog. If not // configured, the ACLToken will be used. ACLAgentToken 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 // ACLReplicationToken is used to fetch ACLs from the ACLDatacenter in // order to replicate them locally. Setting this to a non-empty value // also enables replication. Replication is only available in datacenters // other than the ACLDatacenter. ACLReplicationToken string // ACLReplicationInterval is the interval at which replication passes // will occur. Queries to the ACLDatacenter may block, so replication // can happen less often than this, but the interval forms the upper // limit to how fast we will go if there was constant ACL churn on the // remote end. ACLReplicationInterval time.Duration // ACLReplicationApplyLimit is the max number of replication-related // apply operations that we allow during a one second period. This is // used to limit the amount of Raft bandwidth used for replication. ACLReplicationApplyLimit int // ACLEnforceVersion8 is used to gate a set of ACL policy features that // are opt-in prior to Consul 0.8 and opt-out in Consul 0.8 and later. ACLEnforceVersion8 bool // 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 reasonable 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 // Minimum Session TTL SessionTTLMin 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) // DisableCoordinates controls features related to network coordinates. DisableCoordinates bool // CoordinateUpdatePeriod controls how long a server batches coordinate // updates before applying them in a Raft transaction. A larger period // leads to fewer Raft transactions, but also the stored coordinates // being more stale. CoordinateUpdatePeriod time.Duration // CoordinateUpdateBatchSize controls the maximum number of updates a // server batches before applying them in a Raft transaction. CoordinateUpdateBatchSize int // CoordinateUpdateMaxBatches controls the maximum number of batches we // are willing to apply in one period. After this limit we will issue a // warning and discard the remaining updates. CoordinateUpdateMaxBatches int // RPCHoldTimeout is how long an RPC can be "held" before it is errored. // This is used to paper over a loss of leadership by instead holding RPCs, // so that the caller experiences a slow response rather than an error. // This period is meant to be long enough for a leader election to take // place, and a small jitter is applied to avoid a thundering herd. RPCHoldTimeout time.Duration }
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
func (*Config) GetTokenForAgent ¶ added in v0.7.2
GetTokenForAgent returns the token the agent should use for its own internal operations, such as registering itself with the catalog.
func (*Config) ScaleRaft ¶ added in v0.7.0
ScaleRaft sets the config to have Raft timing parameters scaled by the given performance multiplier. This is done in an idempotent way so it's not tricky to call this when composing configurations and potentially calling this multiple times on the same structure.
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, tlsWrap tlsutil.DCWrapper) *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) Dial ¶ added in v0.7.1
Dial is used to establish a raw connection to the given server.
func (*ConnPool) PingConsulServer ¶ added in v0.7.0
PingConsulServer sends a Status.Ping message to the specified server and returns true if healthy, false if an error occurred
type Coordinate ¶ added in v0.6.0
type Coordinate struct {
// contains filtered or unexported fields
}
Coordinate manages queries and updates for network coordinates.
func NewCoordinate ¶ added in v0.6.0
func NewCoordinate(srv *Server) *Coordinate
NewCoordinate returns a new Coordinate endpoint.
func (*Coordinate) ListDatacenters ¶ added in v0.6.0
func (c *Coordinate) ListDatacenters(args *struct{}, reply *[]structs.DatacenterMap) error
ListDatacenters returns the list of datacenters and their respective nodes and the raw coordinates of those nodes (if no coordinates are available for any of the nodes, the node list may be empty).
func (*Coordinate) ListNodes ¶ added in v0.6.0
func (c *Coordinate) ListNodes(args *structs.DCSpecificRequest, reply *structs.IndexedCoordinates) error
ListNodes returns the list of nodes with their raw network coordinates (if no coordinates are available for a node it won't appear in this list).
func (*Coordinate) Update ¶ added in v0.6.0
func (c *Coordinate) Update(args *structs.CoordinateUpdateRequest, reply *struct{}) (err error)
Update inserts or updates the LAN coordinate of a node.
type Filter ¶ added in v0.4.0
Filter interface is used with FilterEntries to do an in-place filter of a slice.
type HalfCloser ¶ added in v0.7.1
type HalfCloser interface {
CloseWrite() error
}
HalfCloser is an interface that exposes a TCP half-close. We need this because we want to expose the raw TCP connection underlying a TLS one in a way that's hard to screw up and use for anything else. There's a change brewing that will allow us to use the TLS connection for this instead - https://go-review.googlesource.com/#/c/25159/.
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
NodeDump is used to generate information about all of the nodes.
func (*Internal) NodeInfo ¶ added in v0.2.0
func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest, reply *structs.IndexedNodeDump) error
NodeInfo is used to retrieve information about a specific node.
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 update request to the data store.
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 separator.
type Operator ¶ added in v0.7.0
type Operator struct {
// contains filtered or unexported fields
}
Operator endpoint is used to perform low-level operator tasks for Consul.
func (*Operator) RaftGetConfiguration ¶ added in v0.7.0
func (op *Operator) RaftGetConfiguration(args *structs.DCSpecificRequest, reply *structs.RaftConfigurationResponse) error
RaftGetConfiguration is used to retrieve the current Raft configuration.
func (*Operator) RaftRemovePeerByAddress ¶ added in v0.7.0
func (op *Operator) RaftRemovePeerByAddress(args *structs.RaftPeerByAddressRequest, reply *struct{}) error
RaftRemovePeerByAddress is used to kick a stale peer (one that it in the Raft quorum but no longer known to Serf or the catalog) by address in the form of "IP:port". The reply argument is not used, but it required to fulfill the RPC interface.
type PreparedQuery ¶ added in v0.6.0
type PreparedQuery struct {
// contains filtered or unexported fields
}
PreparedQuery manages the prepared query endpoint.
func (*PreparedQuery) Apply ¶ added in v0.6.0
func (p *PreparedQuery) Apply(args *structs.PreparedQueryRequest, reply *string) (err error)
Apply is used to apply a modifying request to the data store. This should only be used for operations that modify the data. The ID of the session is returned in the reply.
func (*PreparedQuery) Execute ¶ added in v0.6.0
func (p *PreparedQuery) Execute(args *structs.PreparedQueryExecuteRequest, reply *structs.PreparedQueryExecuteResponse) error
Execute runs a prepared query and returns the results. This will perform the failover logic if no local results are available. This is typically called as part of a DNS lookup, or when executing prepared queries from the HTTP API.
func (*PreparedQuery) ExecuteRemote ¶ added in v0.6.0
func (p *PreparedQuery) ExecuteRemote(args *structs.PreparedQueryExecuteRemoteRequest, reply *structs.PreparedQueryExecuteResponse) error
ExecuteRemote is used when a local node doesn't have any instances of a service available and needs to probe remote DCs. This sends the full query over since the remote side won't have it in its state store, and this doesn't do the failover logic since that's already being run on the originating DC. We don't want things to fan out further than one level.
func (*PreparedQuery) Explain ¶ added in v0.6.4
func (p *PreparedQuery) Explain(args *structs.PreparedQueryExecuteRequest, reply *structs.PreparedQueryExplainResponse) error
Explain resolves a prepared query and returns the (possibly rendered template) to the caller. This is useful for letting operators figure out which query is picking up a given name. We can also add additional info about how the query will be executed here.
func (*PreparedQuery) Get ¶ added in v0.6.0
func (p *PreparedQuery) Get(args *structs.PreparedQuerySpecificRequest, reply *structs.IndexedPreparedQueries) error
Get returns a single prepared query by ID.
func (*PreparedQuery) List ¶ added in v0.6.0
func (p *PreparedQuery) List(args *structs.DCSpecificRequest, reply *structs.IndexedPreparedQueries) error
List returns all the prepared queries.
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) GetLANCoordinate ¶ added in v0.6.0
func (s *Server) GetLANCoordinate() (*coordinate.Coordinate, error)
GetLANCoordinate returns the coordinate of the server in the LAN gossip pool.
func (*Server) GetWANCoordinate ¶ added in v0.6.0
func (s *Server) GetWANCoordinate() (*coordinate.Coordinate, error)
GetWANCoordinate returns the coordinate of the server in the WAN gossip pool.
func (*Server) InjectEndpoint ¶ added in v0.6.0
InjectEndpoint is used to substitute an endpoint for testing.
func (*Server) IsACLReplicationEnabled ¶ added in v0.7.0
IsACLReplicationEnabled returns true if ACL replication is enabled.
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) SnapshotRPC ¶ added in v0.7.1
func (s *Server) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn SnapshotReplyFn) error
SnapshotRPC dispatches the given snapshot request, reading from the streaming input and writing to the streaming output depending on the operation.
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
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 SnapshotReplyFn ¶ added in v0.7.1
type SnapshotReplyFn func(reply *structs.SnapshotResponse) error
SnapshotReplyFn gets a peek at the reply before the snapshot streams, which is useful for setting headers.
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
func (*StreamClient) Close ¶ added in v0.5.1
func (sc *StreamClient) Close()
type Txn ¶ added in v0.7.0
type Txn struct {
// contains filtered or unexported fields
}
Txn endpoint is used to perform multi-object atomic transactions.
func (*Txn) Apply ¶ added in v0.7.0
func (t *Txn) Apply(args *structs.TxnRequest, reply *structs.TxnResponse) error
Apply is used to apply multiple operations in a single, atomic transaction.
func (*Txn) Read ¶ added in v0.7.0
func (t *Txn) Read(args *structs.TxnReadRequest, reply *structs.TxnReadResponse) error
Read is used to perform a read-only transaction that doesn't modify the state store. This is much more scaleable since it doesn't go through Raft and supports staleness, so this should be preferred if you're just performing reads.
Source Files ¶
- acl.go
- acl_endpoint.go
- acl_replication.go
- catalog_endpoint.go
- client.go
- config.go
- coordinate_endpoint.go
- filter.go
- fsm.go
- health_endpoint.go
- internal_endpoint.go
- kvs_endpoint.go
- leader.go
- merge.go
- operator_endpoint.go
- pool.go
- prepared_query_endpoint.go
- raft_rpc.go
- rpc.go
- rtt.go
- serf.go
- server.go
- session_endpoint.go
- session_ttl.go
- snapshot_endpoint.go
- status_endpoint.go
- txn_endpoint.go
- util.go
Directories ¶
Path | Synopsis |
---|---|
Package agent provides a logical endpoint for Consul agents in the network.
|
Package agent provides a logical endpoint for Consul agents in the network. |
Package servers provides a Manager interface for Manager managed agent.Server objects.
|
Package servers provides a Manager interface for Manager managed agent.Server objects. |