Documentation ¶
Index ¶
- Constants
- Variables
- func ACLDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func ExecScript(script string) (*exec.Cmd, error)
- func FixupCheckType(raw interface{}) error
- func FixupConfigDurations(raw interface{}) error
- func FixupLockDelay(raw interface{}) error
- func GetDNSConfig(conf *config.RuntimeConfig) *dnsConfig
- func MustAsset(name string) []byte
- func NewLocalState(c *config.RuntimeConfig, lg *log.Logger, tokens *token.Store) *localState
- func NodeID() string
- func ParseHost(host string) (string, string, string, error)
- func ParseMetaPair(raw string) (string, string)
- func ParseRelayFactor(n int) (uint8, error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func TestACLConfig() string
- func TestConfig(sources ...config.Source) *config.RuntimeConfig
- func UniqueID() string
- type Agent
- func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType, persist bool, ...) error
- func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.CheckType, persist bool, ...) error
- func (a *Agent) DisableNodeMaintenance()
- func (a *Agent) DisableServiceMaintenance(serviceID string) error
- func (a *Agent) EnableNodeMaintenance(reason, token string)
- func (a *Agent) EnableServiceMaintenance(serviceID, reason, token string) error
- func (a *Agent) ForceLeave(node string) (err error)
- func (a *Agent) GetLANCoordinate() (lib.CoordinateSet, error)
- func (a *Agent) GossipEncrypted() bool
- func (a *Agent) InstallKey(key, token string, relayFactor uint8) (*structs.KeyringResponses, error)
- func (a *Agent) JoinLAN(addrs []string) (n int, err error)
- func (a *Agent) JoinWAN(addrs []string) (n int, err error)
- func (a *Agent) LANMembers() []serf.Member
- func (a *Agent) LastUserEvent() *UserEvent
- func (a *Agent) Leave() error
- func (a *Agent) ListKeys(token string, relayFactor uint8) (*structs.KeyringResponses, error)
- func (a *Agent) LocalMember() serf.Member
- func (a *Agent) PauseSync()
- func (a *Agent) RPC(method string, args interface{}, reply interface{}) error
- func (a *Agent) ReloadCh() chan chan error
- func (a *Agent) ReloadConfig(newCfg *config.RuntimeConfig) error
- func (a *Agent) RemoveCheck(checkID types.CheckID, persist bool) error
- func (a *Agent) RemoveKey(key, token string, relayFactor uint8) (*structs.KeyringResponses, error)
- func (a *Agent) RemoveService(serviceID string, persist bool) error
- func (a *Agent) ResumeSync()
- func (a *Agent) RetryJoinCh() <-chan error
- func (a *Agent) ShutdownAgent() error
- func (a *Agent) ShutdownCh() <-chan struct{}
- func (a *Agent) ShutdownEndpoints()
- func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, ...) error
- func (a *Agent) Start() error
- func (a *Agent) StartSync()
- func (a *Agent) Stats() map[string]map[string]string
- func (a *Agent) TranslateAddress(dc string, addr string, taggedAddresses map[string]string) string
- func (a *Agent) TranslateAddresses(dc string, subj interface{})
- func (a *Agent) UseKey(key, token string, relayFactor uint8) (*structs.KeyringResponses, error)
- func (a *Agent) UserEvent(dc, token string, params *UserEvent) error
- func (a *Agent) UserEvents() []*UserEvent
- func (a *Agent) WANMembers() []serf.Member
- type Blacklist
- type CheckDocker
- type CheckHTTP
- type CheckMonitor
- type CheckNotifier
- type CheckTCP
- type CheckTTL
- type CriticalCheck
- type DNSServer
- type DockerClient
- type HTTPServer
- func (s *HTTPServer) ACLBootstrap(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLReplicationStatus(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) ACLUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentCheckFail(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentCheckPass(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentCheckUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentCheckWarn(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentDeregisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentDeregisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentForceLeave(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentJoin(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentLeave(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentMembers(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentRegisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentReload(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) AgentToken(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogDeregister(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogNodeServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogRegister(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CatalogServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CoordinateDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) CoordinateNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) EventList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) HealthChecksInState(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) HealthNodeChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) HealthServiceChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) HealthServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request)
- func (s *HTTPServer) IsUIEnabled() bool
- func (s *HTTPServer) KVSDelete(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
- func (s *HTTPServer) KVSEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) KVSGet(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
- func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
- func (s *HTTPServer) KVSPut(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
- func (s *HTTPServer) KeyringInstall(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
- func (s *HTTPServer) KeyringList(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
- func (s *HTTPServer) KeyringRemove(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
- func (s *HTTPServer) KeyringUse(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
- func (s *HTTPServer) OperatorAutopilotConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) OperatorKeyringEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) OperatorRaftConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) OperatorRaftPeer(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) OperatorServerHealth(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) PreparedQueryGeneral(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) PreparedQuerySpecific(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) Snapshot(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) StatusLeader(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) StatusPeers(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) Txn(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) UINodeInfo(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) UINodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- func (s *HTTPServer) UIServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
- type MethodNotAllowedError
- type NotifyGroup
- type Self
- type ServiceSummary
- type TestAgent
- type UserEvent
Constants ¶
const ( // MinInterval is the minimal interval between // two checks. Do not allow for a interval below this value. // Otherwise we risk fork bombing a system. MinInterval = time.Second // CheckBufSize is the maximum size of the captured // check output. Prevents an enormous buffer // from being captured CheckBufSize = 4 * 1024 // 4KB // UserAgent is the value of the User-Agent header // for HTTP health checks. UserAgent = "Consul Health Check" )
const ( SerfLANKeyring = "serf/local.keyring" SerfWANKeyring = "serf/remote.keyring" )
const DefaultDockerHost = "unix:///var/run/docker.sock"
const ( // Limit the size of a watch handlers's output to the // last WatchBufSize. Prevents an enormous buffer // from being captured WatchBufSize = 4 * 1024 // 4KB )
Variables ¶
var InvalidDnsRe = regexp.MustCompile(`[^A-Za-z0-9\\-]+`)
var TempDir = os.TempDir()
TempDir defines the base dir for temporary directories.
Functions ¶
func ACLDisabled ¶
func ACLDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error)
ACLDisabled handles if ACL datacenter is not configured
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func ExecScript ¶
ExecScript returns a command to execute a script
func FixupCheckType ¶
func FixupCheckType(raw interface{}) error
func FixupConfigDurations ¶
func FixupConfigDurations(raw interface{}) error
FixupConfigDurations is used to handle parsing the duration fields in the Autopilot config struct
func FixupLockDelay ¶
func FixupLockDelay(raw interface{}) error
FixupLockDelay is used to handle parsing the JSON body to session/create and properly parsing out the lock delay duration value.
func GetDNSConfig ¶ added in v1.0.0
func GetDNSConfig(conf *config.RuntimeConfig) *dnsConfig
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NewLocalState ¶ added in v0.9.0
NewLocalState creates a is used to initialize the local state
func ParseHost ¶ added in v0.9.0
ParseHost verifies that the given host strings is valid. copied from github.com/docker/docker/client.go
func ParseMetaPair ¶
func ParseRelayFactor ¶
ParseRelayFactor validates and converts the given relay factor to uint8
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func TestACLConfig ¶
func TestACLConfig() string
TestACLConfig returns a default configuration for testing an agent with ACLs.
func TestConfig ¶
func TestConfig(sources ...config.Source) *config.RuntimeConfig
TestConfig returns a unique default configuration for testing an agent.
Types ¶
type Agent ¶
type Agent struct { // Output sink for logs LogOutput io.Writer // Used for streaming logs to LogWriter *logger.LogWriter // In-memory sink used for collecting metrics MemSink *metrics.InmemSink // contains filtered or unexported fields }
The agent is the long running process that is run on every machine. It exposes an RPC interface that is used by the CLI to control the agent. The agent runs the query interfaces like HTTP, DNS, and RPC. However, it can run in either a client, or server mode. In server mode, it runs a full Consul server. In client-only mode, it only forwards requests to other Consul servers.
func (*Agent) AddCheck ¶
func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *structs.CheckType, persist bool, token string) error
AddCheck is used to add a health check to the agent. This entry is persistent and the agent will make a best effort to ensure it is registered. The Check may include a CheckType which is used to automatically update the check status
func (*Agent) AddService ¶
func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.CheckType, persist bool, token string) error
AddService is used to add a service entry. This entry is persistent and the agent will make a best effort to ensure it is registered
func (*Agent) DisableNodeMaintenance ¶
func (a *Agent) DisableNodeMaintenance()
DisableNodeMaintenance removes a node from maintenance mode
func (*Agent) DisableServiceMaintenance ¶
DisableServiceMaintenance will deregister the fake maintenance mode check if the service has been marked as in maintenance.
func (*Agent) EnableNodeMaintenance ¶
EnableNodeMaintenance places a node into maintenance mode.
func (*Agent) EnableServiceMaintenance ¶
EnableServiceMaintenance will register a false health check against the given service ID with critical status. This will exclude the service from queries.
func (*Agent) ForceLeave ¶
ForceLeave is used to remove a failed node from the cluster
func (*Agent) GetLANCoordinate ¶
func (a *Agent) GetLANCoordinate() (lib.CoordinateSet, error)
GetLANCoordinate returns the coordinates of this node in the local pools (assumes coordinates are enabled, so check that before calling).
func (*Agent) GossipEncrypted ¶
func (*Agent) InstallKey ¶
InstallKey installs a new gossip encryption key
func (*Agent) LANMembers ¶
LANMembers is used to retrieve the LAN members
func (*Agent) LastUserEvent ¶
LastUserEvent is used to return the lastest user event. This will return nil if there is no recent event.
func (*Agent) ListKeys ¶
ListKeys lists out all keys installed on the collective Consul cluster. This includes both servers and clients in all DC's.
func (*Agent) LocalMember ¶
LocalMember is used to return the local node
func (*Agent) PauseSync ¶
func (a *Agent) PauseSync()
PauseSync is used to pause anti-entropy while bulk changes are make
func (*Agent) RPC ¶
RPC is used to make an RPC call to the Consul servers This allows the agent to implement the Consul.Interface
func (*Agent) ReloadCh ¶
ReloadCh is used to return a channel that can be used for triggering reloads and returning a response.
func (*Agent) ReloadConfig ¶
func (a *Agent) ReloadConfig(newCfg *config.RuntimeConfig) error
func (*Agent) RemoveCheck ¶
RemoveCheck is used to remove a health check. The agent will make a best effort to ensure it is deregistered
func (*Agent) RemoveService ¶
RemoveService is used to remove a service entry. The agent will make a best effort to ensure it is deregistered
func (*Agent) ResumeSync ¶
func (a *Agent) ResumeSync()
ResumeSync is used to unpause anti-entropy after bulk changes are make
func (*Agent) RetryJoinCh ¶
RetryJoinCh is a channel that transports errors from the retry join process.
func (*Agent) ShutdownAgent ¶
ShutdownAgent is used to hard stop the agent. Should be preceded by Leave to do it gracefully. Should be followed by ShutdownEndpoints to terminate the HTTP and DNS servers as well.
func (*Agent) ShutdownCh ¶
func (a *Agent) ShutdownCh() <-chan struct{}
ShutdownCh is used to return a channel that can be selected to wait for the agent to perform a shutdown.
func (*Agent) ShutdownEndpoints ¶
func (a *Agent) ShutdownEndpoints()
ShutdownEndpoints terminates the HTTP and DNS servers. Should be preceeded by ShutdownAgent.
func (*Agent) SnapshotRPC ¶
func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn structs.SnapshotReplyFn) error
SnapshotRPC performs the requested snapshot RPC against the Consul server in a streaming manner. The contents of in will be read and passed along as the payload, and the response message will determine the error status, and any return payload will be written to out.
func (*Agent) StartSync ¶
func (a *Agent) StartSync()
StartSync is called once Services and Checks are registered. This is called to prevent a race between clients and the anti-entropy routines
func (*Agent) TranslateAddress ¶ added in v0.9.0
TranslateAddress is used to provide the final, translated address for a node, depending on how the agent and the other node are configured. The dc parameter is the dc the datacenter this node is from.
func (*Agent) TranslateAddresses ¶ added in v0.9.0
TranslateAddresses translates addresses in the given structure into the final, translated address, depending on how the agent and the other node are configured. The dc parameter is the datacenter this structure is from.
func (*Agent) UserEvents ¶
UserEvents is used to return a slice of the most recent user events.
func (*Agent) WANMembers ¶
WANMembers is used to retrieve the WAN members
type Blacklist ¶ added in v0.9.0
type Blacklist struct {
// contains filtered or unexported fields
}
Blacklist implements an HTTP endpoint blacklist based on a list of endpoint prefixes which should be blocked.
func NewBlacklist ¶ added in v0.9.0
NewBlacklist returns a blacklist for the given list of prefixes.
type CheckDocker ¶
type CheckDocker struct { Notify CheckNotifier CheckID types.CheckID Script string DockerContainerID string Shell string Interval time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckDocker is used to periodically invoke a script to determine the health of an application running inside a Docker Container. We assume that the script is compatible with nagios plugins and expects the output in the same format.
func (*CheckDocker) Start ¶
func (c *CheckDocker) Start()
func (*CheckDocker) Stop ¶
func (c *CheckDocker) Stop()
type CheckHTTP ¶
type CheckHTTP struct { Notify CheckNotifier CheckID types.CheckID HTTP string Header map[string][]string Method string Interval time.Duration Timeout time.Duration Logger *log.Logger TLSSkipVerify bool // contains filtered or unexported fields }
CheckHTTP is used to periodically make an HTTP request to determine the health of a given check. The check is passing if the response code is 2XX. The check is warning if the response code is 429. The check is critical if the response code is anything else or if the request returns an error
type CheckMonitor ¶
type CheckMonitor struct { Notify CheckNotifier CheckID types.CheckID Script string Interval time.Duration Timeout time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckMonitor is used to periodically invoke a script to determine the health of a given check. It is compatible with nagios plugins and expects the output in the same format.
func (*CheckMonitor) Start ¶
func (c *CheckMonitor) Start()
Start is used to start a check monitor. Monitor runs until stop is called
type CheckNotifier ¶
CheckNotifier interface is used by the CheckMonitor to notify when a check has a status update. The update should take care to be idempotent.
type CheckTCP ¶
type CheckTCP struct { Notify CheckNotifier CheckID types.CheckID TCP string Interval time.Duration Timeout time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckTCP is used to periodically make an TCP/UDP connection to determine the health of a given check. The check is passing if the connection succeeds The check is critical if the connection returns an error
type CheckTTL ¶
type CheckTTL struct { Notify CheckNotifier CheckID types.CheckID TTL time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckTTL is used to apply a TTL to check status, and enables clients to set the status of a check but upon the TTL expiring, the check status is automatically set to critical.
func (*CheckTTL) SetStatus ¶
SetStatus is used to update the status of the check, and to renew the TTL. If expired, TTL is restarted.
type CriticalCheck ¶
type CriticalCheck struct { CriticalFor time.Duration Check *structs.HealthCheck }
CriticalCheck is used to return the duration a check has been critical along with its associated health check.
type DNSServer ¶
DNSServer is used to wrap an Agent and expose various service discovery endpoints using a DNS interface.
func NewDNSServer ¶
func (*DNSServer) ListenAndServe ¶
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient is a simplified client for the Docker Engine API to execute the health checks and avoid significant dependencies. It also consumes all data returned from the Docker API through a ring buffer with a fixed limit to avoid excessive resource consumption.
func NewDockerClient ¶ added in v0.9.0
func NewDockerClient(host string, maxbuf int64) (*DockerClient, error)
func (*DockerClient) CreateExec ¶
func (c *DockerClient) CreateExec(containerID string, cmd []string) (string, error)
func (*DockerClient) InspectExec ¶
func (c *DockerClient) InspectExec(containerID, execID string) (int, error)
type HTTPServer ¶
HTTPServer provides an HTTP api for an agent.
func NewHTTPServer ¶
func NewHTTPServer(addr net.Addr, a *Agent) *HTTPServer
func (*HTTPServer) ACLBootstrap ¶ added in v0.9.1
func (s *HTTPServer) ACLBootstrap(resp http.ResponseWriter, req *http.Request) (interface{}, error)
ACLBootstrap is used to perform a one-time ACL bootstrap operation on a cluster to get the first management token.
func (*HTTPServer) ACLClone ¶
func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLCreate ¶
func (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLDestroy ¶
func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLGet ¶
func (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLList ¶
func (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLReplicationStatus ¶
func (s *HTTPServer) ACLReplicationStatus(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLUpdate ¶
func (s *HTTPServer) ACLUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentCheckFail ¶
func (s *HTTPServer) AgentCheckFail(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentCheckPass ¶
func (s *HTTPServer) AgentCheckPass(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentCheckUpdate ¶
func (s *HTTPServer) AgentCheckUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
AgentCheckUpdate is a PUT-based alternative to the GET-based Pass/Warn/Fail APIs.
func (*HTTPServer) AgentCheckWarn ¶
func (s *HTTPServer) AgentCheckWarn(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentChecks ¶
func (s *HTTPServer) AgentChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentDeregisterCheck ¶
func (s *HTTPServer) AgentDeregisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentDeregisterService ¶
func (s *HTTPServer) AgentDeregisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentForceLeave ¶
func (s *HTTPServer) AgentForceLeave(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentJoin ¶
func (s *HTTPServer) AgentJoin(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentLeave ¶
func (s *HTTPServer) AgentLeave(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentMembers ¶
func (s *HTTPServer) AgentMembers(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentMetrics ¶ added in v0.9.1
func (s *HTTPServer) AgentMetrics(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentMonitor ¶
func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentNodeMaintenance ¶
func (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentRegisterCheck ¶
func (s *HTTPServer) AgentRegisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentRegisterService ¶
func (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentReload ¶
func (s *HTTPServer) AgentReload(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentSelf ¶
func (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentServiceMaintenance ¶
func (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentServices ¶
func (s *HTTPServer) AgentServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentToken ¶ added in v0.9.1
func (s *HTTPServer) AgentToken(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogDatacenters ¶
func (s *HTTPServer) CatalogDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogDeregister ¶
func (s *HTTPServer) CatalogDeregister(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogNodeServices ¶
func (s *HTTPServer) CatalogNodeServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogNodes ¶
func (s *HTTPServer) CatalogNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogRegister ¶
func (s *HTTPServer) CatalogRegister(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogServiceNodes ¶
func (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CatalogServices ¶
func (s *HTTPServer) CatalogServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) CoordinateDatacenters ¶
func (s *HTTPServer) CoordinateDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error)
CoordinateDatacenters returns the WAN nodes in each datacenter, along with raw network coordinates.
func (*HTTPServer) CoordinateNodes ¶
func (s *HTTPServer) CoordinateNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
CoordinateNodes returns the LAN nodes in the given datacenter, along with raw network coordinates.
func (*HTTPServer) EventFire ¶
func (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error)
EventFire is used to fire a new event
func (*HTTPServer) EventList ¶
func (s *HTTPServer) EventList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
EventList is used to retrieve the recent list of events
func (*HTTPServer) HealthChecksInState ¶
func (s *HTTPServer) HealthChecksInState(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) HealthNodeChecks ¶
func (s *HTTPServer) HealthNodeChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) HealthServiceChecks ¶
func (s *HTTPServer) HealthServiceChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) HealthServiceNodes ¶
func (s *HTTPServer) HealthServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) Index ¶
func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request)
Renders a simple index page
func (*HTTPServer) IsUIEnabled ¶
func (s *HTTPServer) IsUIEnabled() bool
Returns true if the UI is enabled.
func (*HTTPServer) KVSDelete ¶
func (s *HTTPServer) KVSDelete(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
KVSPut handles a DELETE request
func (*HTTPServer) KVSEndpoint ¶
func (s *HTTPServer) KVSEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) KVSGet ¶
func (s *HTTPServer) KVSGet(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
KVSGet handles a GET request
func (*HTTPServer) KVSGetKeys ¶
func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
KVSGetKeys handles a GET request for keys
func (*HTTPServer) KVSPut ¶
func (s *HTTPServer) KVSPut(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)
KVSPut handles a PUT request
func (*HTTPServer) KeyringInstall ¶
func (s *HTTPServer) KeyringInstall(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
KeyringInstall is used to install a new gossip encryption key into the cluster
func (*HTTPServer) KeyringList ¶
func (s *HTTPServer) KeyringList(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
KeyringList is used to list the keys installed in the cluster
func (*HTTPServer) KeyringRemove ¶
func (s *HTTPServer) KeyringRemove(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
KeyringRemove is used to list the keys installed in the cluster
func (*HTTPServer) KeyringUse ¶
func (s *HTTPServer) KeyringUse(resp http.ResponseWriter, req *http.Request, args *keyringArgs) (interface{}, error)
KeyringUse is used to change the primary gossip encryption key
func (*HTTPServer) OperatorAutopilotConfiguration ¶
func (s *HTTPServer) OperatorAutopilotConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorAutopilotConfiguration is used to inspect the current Autopilot configuration. This supports the stale query mode in case the cluster doesn't have a leader.
func (*HTTPServer) OperatorKeyringEndpoint ¶
func (s *HTTPServer) OperatorKeyringEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorKeyringEndpoint handles keyring operations (install, list, use, remove)
func (*HTTPServer) OperatorRaftConfiguration ¶
func (s *HTTPServer) OperatorRaftConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorRaftConfiguration is used to inspect the current Raft configuration. This supports the stale query mode in case the cluster doesn't have a leader.
func (*HTTPServer) OperatorRaftPeer ¶
func (s *HTTPServer) OperatorRaftPeer(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorRaftPeer supports actions on Raft peers. Currently we only support removing peers by address.
func (*HTTPServer) OperatorServerHealth ¶
func (s *HTTPServer) OperatorServerHealth(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorServerHealth is used to get the health of the servers in the local DC
func (*HTTPServer) PreparedQueryGeneral ¶
func (s *HTTPServer) PreparedQueryGeneral(resp http.ResponseWriter, req *http.Request) (interface{}, error)
PreparedQueryGeneral handles all the general prepared query requests.
func (*HTTPServer) PreparedQuerySpecific ¶
func (s *HTTPServer) PreparedQuerySpecific(resp http.ResponseWriter, req *http.Request) (interface{}, error)
PreparedQuerySpecific handles all the prepared query requests specific to a particular query.
func (*HTTPServer) SessionCreate ¶
func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionCreate is used to create a new session
func (*HTTPServer) SessionDestroy ¶
func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionDestroy is used to destroy an existing session
func (*HTTPServer) SessionGet ¶
func (s *HTTPServer) SessionGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionGet is used to get info for a particular session
func (*HTTPServer) SessionList ¶
func (s *HTTPServer) SessionList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionList is used to list all the sessions
func (*HTTPServer) SessionRenew ¶
func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionRenew is used to renew the TTL on an existing TTL session
func (*HTTPServer) SessionsForNode ¶
func (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionsForNode returns all the nodes belonging to a node
func (*HTTPServer) Snapshot ¶
func (s *HTTPServer) Snapshot(resp http.ResponseWriter, req *http.Request) (interface{}, error)
Snapshot handles requests to take and restore snapshots. This uses a special mechanism to make the RPC since we potentially stream large amounts of data as part of these requests.
func (*HTTPServer) StatusLeader ¶
func (s *HTTPServer) StatusLeader(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) StatusPeers ¶
func (s *HTTPServer) StatusPeers(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) Txn ¶
func (s *HTTPServer) Txn(resp http.ResponseWriter, req *http.Request) (interface{}, error)
Txn handles requests to apply multiple operations in a single, atomic transaction. A transaction consisting of only read operations will be fast- pathed to an endpoint that supports consistency modes (but not blocking), and everything else will be routed through Raft like a normal write.
func (*HTTPServer) UINodeInfo ¶
func (s *HTTPServer) UINodeInfo(resp http.ResponseWriter, req *http.Request) (interface{}, error)
UINodeInfo is used to get info on a single node in a given datacenter. We return a NodeInfo which provides overview information for the node
func (*HTTPServer) UINodes ¶
func (s *HTTPServer) UINodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)
UINodes is used to list the nodes in a given datacenter. We return a NodeDump which provides overview information for all the nodes
func (*HTTPServer) UIServices ¶
func (s *HTTPServer) UIServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)
UIServices is used to list the services in a given datacenter. We return a ServiceSummary which provides overview information for the service
type MethodNotAllowedError ¶ added in v1.0.0
MethodNotAllowedError should be returned by a handler when the HTTP method is not allowed.
func (MethodNotAllowedError) Error ¶ added in v1.0.0
func (e MethodNotAllowedError) Error() string
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) Clear ¶
func (n *NotifyGroup) Clear(ch chan struct{})
Clear removes a channel from the notify group
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 Self ¶
type Self struct { Config map[string]interface{} Coord *coordinate.Coordinate Member serf.Member Stats map[string]map[string]string Meta map[string]string }
type ServiceSummary ¶
type ServiceSummary struct { Name string Nodes []string ChecksPassing int ChecksWarning int ChecksCritical int }
ServiceSummary is used to summarize a service
type TestAgent ¶
type TestAgent struct { // Name is an optional name of the agent. Name string HCL string // Config is the agent configuration. If Config is nil then // TestConfig() is used. If Config.DataDir is set then it is // the callers responsibility to clean up the data directory. // Otherwise, a temporary data directory is created and removed // when Shutdown() is called. Config *config.RuntimeConfig // LogOutput is the sink for the logs. If nil, logs are written // to os.Stderr. LogOutput io.Writer // LogWriter is used for streaming logs. LogWriter *logger.LogWriter // DataDir is the data directory which is used when Config.DataDir // is not set. It is created automatically and removed when // Shutdown() is called. DataDir string // Key is the optional encryption key for the LAN and WAN keyring. Key string // NoInitialSync determines whether an anti-entropy run // will be scheduled after the agent started. NoInitialSync bool // Agent is the embedded consul agent. // It is valid after Start(). *Agent // contains filtered or unexported fields }
TestAgent encapsulates an Agent with a default configuration and startup procedure suitable for testing. It panics if there are errors during creation or startup instead of returning errors. It manages a temporary data directory which is removed after shutdown.
func NewTestAgent ¶
NewTestAgent returns a started agent with the given name and configuration. It panics if the agent could not be started. The caller should call Shutdown() to stop the agent and remove temporary directories.
func (*TestAgent) DNSDisableCompression ¶ added in v0.9.0
DNSDisableCompression disables compression for all started DNS servers.
func (*TestAgent) SegmentAddr ¶ added in v0.9.3
type UserEvent ¶
type UserEvent struct { // ID of the user event. Automatically generated. ID string // Name of the event Name string `codec:"n"` // Optional payload Payload []byte `codec:"p,omitempty"` // NodeFilter is a regular expression to filter on nodes NodeFilter string `codec:"nf,omitempty"` // ServiceFilter is a regular expression to filter on services ServiceFilter string `codec:"sf,omitempty"` // TagFilter is a regular expression to filter on tags of a service, // must be provided with ServiceFilter TagFilter string `codec:"tf,omitempty"` // Version of the user event. Automatically generated. Version int `codec:"v"` // LTime is the lamport time. Automatically generated. LTime uint64 `codec:"-"` }
UserEventParam is used to parameterize a user event
Source Files ¶
- acl.go
- acl_endpoint.go
- agent.go
- agent_endpoint.go
- bindata_assetfs.go
- blacklist.go
- catalog_endpoint.go
- check.go
- config.go
- coordinate_endpoint.go
- dns.go
- docker.go
- docker_unix.go
- event_endpoint.go
- health_endpoint.go
- http.go
- keyring.go
- kvs_endpoint.go
- local.go
- notify.go
- operator_endpoint.go
- prepared_query_endpoint.go
- remote_exec.go
- retry_join.go
- segment_stub.go
- session_endpoint.go
- snapshot_endpoint.go
- status_endpoint.go
- testagent.go
- translate_addr.go
- txn_endpoint.go
- ui_endpoint.go
- user_event.go
- util.go
- util_other.go
- watch_handler.go
Directories ¶
Path | Synopsis |
---|---|
The snapshot endpoint is a special non-RPC endpoint that supports streaming for taking and restoring snapshots for disaster recovery.
|
The snapshot endpoint is a special non-RPC endpoint that supports streaming for taking and restoring snapshots for disaster recovery. |
Package servers provides a Manager interface for Manager managed metadata.Server objects.
|
Package servers provides a Manager interface for Manager managed metadata.Server objects. |