Documentation ¶
Index ¶
- Constants
- 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 Bool(b bool) *bool
- func ExecScript(script string) (*exec.Cmd, error)
- func FixupCheckType(raw interface{}) error
- func FixupLockDelay(raw interface{}) error
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type AddressConfig
- type AdvertiseAddrsConfig
- type Agent
- func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist bool, token string) error
- func (a *Agent) AddService(service *structs.NodeService, chkTypes CheckTypes, persist bool, token string) 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) GetCoordinate() (*coordinate.Coordinate, error)
- func (a *Agent) InjectEndpoint(endpoint string, handler interface{}) error
- func (a *Agent) InstallKey(key, token string) (*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) (*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) RemoveCheck(checkID types.CheckID, persist bool) error
- func (a *Agent) RemoveKey(key, token string) (*structs.KeyringResponses, error)
- func (a *Agent) RemoveService(serviceID string, persist bool) error
- func (a *Agent) ResumeSync()
- func (a *Agent) Shutdown() error
- func (a *Agent) ShutdownCh() <-chan struct{}
- func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, ...) error
- func (a *Agent) StartSync()
- func (a *Agent) Stats() map[string]map[string]string
- func (a *Agent) UseKey(key, token string) (*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 AgentRPC
- type AgentSelf
- type AppendSliceValue
- type CheckDefinition
- type CheckDocker
- type CheckHTTP
- type CheckMonitor
- type CheckNotifier
- type CheckTCP
- type CheckTTL
- type CheckType
- type CheckTypes
- type Command
- type Config
- type CriticalCheck
- type DNSConfig
- type DNSServer
- type DockerClient
- type FilePermissions
- type HTTPServer
- 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) 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) 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) 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) 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) Shutdown()
- 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 KeyringEntry
- type KeyringInfo
- type KeyringMessage
- type Member
- type Performance
- type PortConfig
- type RPCClient
- func (c *RPCClient) Close() error
- func (c *RPCClient) ForceLeave(node string) error
- func (c *RPCClient) InstallKey(key, token string) (keyringResponse, error)
- func (c *RPCClient) Join(addrs []string, wan bool) (int, error)
- func (c *RPCClient) LANMembers() ([]Member, error)
- func (c *RPCClient) Leave() error
- func (c *RPCClient) ListKeys(token string) (keyringResponse, error)
- func (c *RPCClient) Monitor(level logutils.LogLevel, ch chan<- string) (StreamHandle, error)
- func (c *RPCClient) Reload() error
- func (c *RPCClient) RemoveKey(key, token string) (keyringResponse, error)
- func (c *RPCClient) Stats() (map[string]map[string]string, error)
- func (c *RPCClient) Stop(handle StreamHandle) error
- func (c *RPCClient) UseKey(key, token string) (keyringResponse, error)
- func (c *RPCClient) WANMembers() ([]Member, error)
- type RetryJoinEC2
- type ServiceDefinition
- type ServiceSummary
- type StreamHandle
- type Telemetry
- type UnixSocketConfig
- type UnixSocketPermissions
- type UserEvent
Constants ¶
const ( // Do not allow for a interval below this value. // Otherwise we risk fork bombing a system. MinInterval = time.Second // Limit the size of a check's output to the // last CheckBufSize. Prevents an enormous buffer // from being captured CheckBufSize = 4 * 1024 // 4KB // Use this user agent when doing requests for // HTTP health checks. HttpUserAgent = "Consul Health Check" )
const ( MinRPCVersion = 1 MaxRPCVersion = 1 )
const ( // RPCAddrEnvName defines an environment variable name which sets // an RPC address if there is no -rpc-addr specified. RPCAddrEnvName = "CONSUL_RPC_ADDR" )
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 ¶
This section is empty.
Functions ¶
func ACLDisabled ¶ added in v0.7.2
func ACLDisabled(resp http.ResponseWriter, req *http.Request) (interface{}, error)
ACLDisabled handles if ACL datacenter is not configured
func Asset ¶ added in v0.6.1
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 ¶ added in v0.6.1
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 ¶ added in v0.6.1
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 AssetNames ¶ added in v0.6.1
func AssetNames() []string
AssetNames returns the names of the assets.
func ExecScript ¶ added in v0.4.0
ExecScript returns a command to execute a script
func FixupCheckType ¶
func FixupCheckType(raw interface{}) error
func FixupLockDelay ¶ added in v0.3.0
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 MustAsset ¶ added in v0.6.1
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶ added in v0.6.1
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶ added in v0.6.1
RestoreAssets restores an asset under the given directory recursively
Types ¶
type AddressConfig ¶ added in v0.4.0
type AddressConfig struct { DNS string // DNS Query interface HTTP string // HTTP API HTTPS string // HTTPS API RPC string // CLI RPC }
AddressConfig is used to provide address overrides for specific services. By default, either ClientAddress or ServerAddress is used.
type AdvertiseAddrsConfig ¶ added in v0.6.0
type Agent ¶
type Agent struct {
// 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 Create ¶
func Create(config *Config, logOutput io.Writer, logWriter *logger.LogWriter, reloadCh chan chan error) (*Agent, error)
Create is used to create a new Agent. Returns the agent or potentially an error.
func (*Agent) AddCheck ¶
func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *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 CheckTypes, 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 ¶ added in v0.5.0
func (a *Agent) DisableNodeMaintenance()
DisableNodeMaintenance removes a node from maintenance mode
func (*Agent) DisableServiceMaintenance ¶ added in v0.5.0
DisableServiceMaintenance will deregister the fake maintenance mode check if the service has been marked as in maintenance.
func (*Agent) EnableNodeMaintenance ¶ added in v0.5.0
EnableNodeMaintenance places a node into maintenance mode.
func (*Agent) EnableServiceMaintenance ¶ added in v0.5.0
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) GetCoordinate ¶ added in v0.6.0
func (a *Agent) GetCoordinate() (*coordinate.Coordinate, error)
Returns the coordinate of this node in the local pool (assumes coordinates are enabled, so check that before calling).
func (*Agent) InjectEndpoint ¶ added in v0.6.0
InjectEndpoint overrides the given endpoint with a substitute one. Note that not all agent methods use this mechanism, and that is should only be used for testing.
func (*Agent) InstallKey ¶ added in v0.5.0
func (a *Agent) InstallKey(key, token string) (*structs.KeyringResponses, error)
InstallKey installs a new gossip encryption key
func (*Agent) LANMembers ¶
LANMembers is used to retrieve the LAN members
func (*Agent) LastUserEvent ¶ added in v0.4.0
LastUserEvent is used to return the lastest user event. This will return nil if there is no recent event.
func (*Agent) ListKeys ¶ added in v0.5.0
func (a *Agent) ListKeys(token string) (*structs.KeyringResponses, error)
ListKeys lists out all keys installed on the collective Consul cluster. This includes both servers and clients in all DC's.
func (*Agent) LocalMember ¶ added in v0.3.0
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) RemoveCheck ¶
RemoveCheck is used to remove a health check. The agent will make a best effort to ensure it is deregistered
func (*Agent) RemoveKey ¶ added in v0.5.0
func (a *Agent) RemoveKey(key, token string) (*structs.KeyringResponses, error)
RemoveKey will remove a gossip encryption key from the keyring
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) Shutdown ¶
Shutdown is used to hard stop the agent. Should be preceded by a call to Leave to do it gracefully.
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) SnapshotRPC ¶ added in v0.7.1
func (a *Agent) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn consul.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) UseKey ¶ added in v0.5.0
func (a *Agent) UseKey(key, token string) (*structs.KeyringResponses, error)
UseKey changes the primary encryption key used to encrypt messages
func (*Agent) UserEvent ¶ added in v0.4.0
UserEvent is used to fire an event via the Serf layer on the LAN
func (*Agent) UserEvents ¶ added in v0.4.0
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 AgentRPC ¶
func NewAgentRPC ¶
func NewAgentRPC(agent *Agent, listener net.Listener, logOutput io.Writer, logWriter *logger.LogWriter) *AgentRPC
NewAgentRPC is used to create a new Agent RPC handler
type AgentSelf ¶ added in v0.3.0
type AgentSelf struct { Config *Config Coord *coordinate.Coordinate Member serf.Member Stats map[string]map[string]string }
type AppendSliceValue ¶
type AppendSliceValue []string
AppendSliceValue implements the flag.Value interface and allows multiple calls to the same variable to append a list.
func (*AppendSliceValue) Set ¶
func (s *AppendSliceValue) Set(value string) error
func (*AppendSliceValue) String ¶
func (s *AppendSliceValue) String() string
type CheckDefinition ¶
type CheckDefinition struct { ID types.CheckID Name string Notes string ServiceID string Token string Status string CheckType `mapstructure:",squash"` }
CheckDefinition is used to JSON decode the Check definitions
func DecodeCheckDefinition ¶
func DecodeCheckDefinition(raw interface{}) (*CheckDefinition, error)
DecodeCheckDefinition is used to decode a check definition
func (*CheckDefinition) HealthCheck ¶
func (c *CheckDefinition) HealthCheck(node string) *structs.HealthCheck
type CheckDocker ¶ added in v0.6.0
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) Init ¶ added in v0.6.0
func (c *CheckDocker) Init() error
Initializes the Docker Client
func (*CheckDocker) Start ¶ added in v0.6.0
func (c *CheckDocker) Start()
Start is used to start checks. Docker Checks runs until stop is called
func (*CheckDocker) Stop ¶ added in v0.6.0
func (c *CheckDocker) Stop()
Stop is used to stop a docker check.
type CheckHTTP ¶ added in v0.5.0
type CheckHTTP struct { Notify CheckNotifier CheckID types.CheckID HTTP 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 ¶ added in v0.6.0
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 CheckType ¶
type CheckType struct { Script string HTTP string TCP string Interval time.Duration DockerContainerID string Shell string TLSSkipVerify bool Timeout time.Duration TTL time.Duration // DeregisterCriticalServiceAfter, if >0, will cause the associated // service, if any, to be deregistered if this check is critical for // longer than this duration. DeregisterCriticalServiceAfter time.Duration Status string Notes string }
CheckType is used to create either the CheckMonitor or the CheckTTL. Five types are supported: Script, HTTP, TCP, Docker and TTL. Script, HTTP, Docker and TCP all require Interval. Only one of the types may to be provided: TTL or Script/Interval or HTTP/Interval or TCP/Interval or Docker/Interval.
type CheckTypes ¶ added in v0.5.0
type CheckTypes []*CheckType
type Command ¶
type Command struct { Revision string Version string VersionPrerelease string HumanVersion string Ui cli.Ui ShutdownCh <-chan struct{} // contains filtered or unexported fields }
Command is a Command implementation that runs a Consul agent. The command will not end unless a shutdown message is sent on the ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly exit.
type Config ¶
type Config struct { // DevMode enables a fast-path mode of operation to bring up an in-memory // server with minimal configuration. Useful for developing Consul. DevMode bool `mapstructure:"-"` // Performance is used to tune the performance of Consul's subsystems. Performance Performance `mapstructure:"performance"` // Bootstrap is used to bring up the first Consul server, and // permits that node to elect itself leader Bootstrap bool `mapstructure:"bootstrap"` // BootstrapExpect tries to automatically bootstrap the Consul cluster, // by withholding peers until enough servers join. BootstrapExpect int `mapstructure:"bootstrap_expect"` // Server controls if this agent acts like a Consul server, // or merely as a client. Servers have more state, take part // in leader election, etc. Server bool `mapstructure:"server"` // Datacenter is the datacenter this node is in. Defaults to dc1 Datacenter string `mapstructure:"datacenter"` // DataDir is the directory to store our state in DataDir string `mapstructure:"data_dir"` // DNSRecursors can be set to allow the DNS servers to recursively // resolve non-consul domains. It is deprecated, and merges into the // recursors array. DNSRecursor string `mapstructure:"recursor"` // DNSRecursors can be set to allow the DNS servers to recursively // resolve non-consul domains DNSRecursors []string `mapstructure:"recursors"` // DNS configuration DNSConfig DNSConfig `mapstructure:"dns_config"` // Domain is the DNS domain for the records. Defaults to "consul." Domain string `mapstructure:"domain"` // Encryption key to use for the Serf communication EncryptKey string `mapstructure:"encrypt" json:"-"` // LogLevel is the level of the logs to putout LogLevel string `mapstructure:"log_level"` // Node name is the name we use to advertise. Defaults to hostname. NodeName string `mapstructure:"node_name"` // ClientAddr is used to control the address we bind to for // client services (DNS, HTTP, HTTPS, RPC) ClientAddr string `mapstructure:"client_addr"` // BindAddr is used to control the address we bind to. // If not specified, the first private IP we find is used. // This controls the address we use for cluster facing // services (Gossip, Server RPC) BindAddr string `mapstructure:"bind_addr"` // SerfWanBindAddr is used to control the address we bind to. // If not specified, the first private IP we find is used. // This controls the address we use for cluster facing // services (Gossip) Serf SerfWanBindAddr string `mapstructure:"serf_wan_bind"` // SerfLanBindAddr is used to control the address we bind to. // If not specified, the first private IP we find is used. // This controls the address we use for cluster facing // services (Gossip) Serf SerfLanBindAddr string `mapstructure:"serf_lan_bind"` // AdvertiseAddr is the address we use for advertising our Serf, // and Consul RPC IP. If not specified, bind address is used. AdvertiseAddr string `mapstructure:"advertise_addr"` // AdvertiseAddrs configuration AdvertiseAddrs AdvertiseAddrsConfig `mapstructure:"advertise_addrs"` // AdvertiseAddrWan is the address we use for advertising our // Serf WAN IP. If not specified, the general advertise address is used. AdvertiseAddrWan string `mapstructure:"advertise_addr_wan"` // TranslateWanAddrs controls whether or not Consul should prefer // the "wan" tagged address when doing lookups in remote datacenters. // See TaggedAddresses below for more details. TranslateWanAddrs bool `mapstructure:"translate_wan_addrs"` // Port configurations Ports PortConfig // Address configurations Addresses AddressConfig // Tagged addresses. These are used to publish a set of addresses for // for a node, which can be used by the remote agent. We currently // populate only the "wan" tag based on the SerfWan advertise address, // but this structure is here for possible future features with other // user-defined tags. The "wan" tag will be used by remote agents if // they are configured with TranslateWanAddrs set to true. TaggedAddresses map[string]string // LeaveOnTerm controls if Serf does a graceful leave when receiving // the TERM signal. Defaults true on clients, false on servers. This can // be changed on reload. LeaveOnTerm *bool `mapstructure:"leave_on_terminate"` // SkipLeaveOnInt controls if Serf skips a graceful leave when // receiving the INT signal. Defaults false on clients, true on // servers. This can be changed on reload. SkipLeaveOnInt *bool `mapstructure:"skip_leave_on_interrupt"` Telemetry Telemetry `mapstructure:"telemetry"` // Protocol is the Consul protocol version to use. Protocol int `mapstructure:"protocol"` // EnableDebug is used to enable various debugging features EnableDebug bool `mapstructure:"enable_debug"` // 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 `mapstructure:"verify_incoming"` // VerifyOutgoing is used to verify the authenticity of outgoing connections. // This means that TLS requests are used. TLS connections must match a provided // certificate authority. This is used to verify authenticity of server nodes. VerifyOutgoing bool `mapstructure:"verify_outgoing"` // 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 `mapstructure:"verify_server_hostname"` // CAFile is a path to a certificate authority file. This is used with VerifyIncoming // or VerifyOutgoing to verify the TLS connection. CAFile string `mapstructure:"ca_file"` // CertFile is used to provide a TLS certificate that is used for serving TLS connections. // Must be provided to serve TLS connections. CertFile string `mapstructure:"cert_file"` // KeyFile is used to provide a TLS key that is used for serving TLS connections. // Must be provided to serve TLS connections. KeyFile string `mapstructure:"key_file"` // ServerName is used with the TLS certificates to ensure the name we // provide matches the certificate ServerName string `mapstructure:"server_name"` // StartJoin is a list of addresses to attempt to join when the // agent starts. If Serf is unable to communicate with any of these // addresses, then the agent will error and exit. StartJoin []string `mapstructure:"start_join"` // StartJoinWan is a list of addresses to attempt to join -wan when the // agent starts. If Serf is unable to communicate with any of these // addresses, then the agent will error and exit. StartJoinWan []string `mapstructure:"start_join_wan"` // RetryJoin is a list of addresses to join with retry enabled. RetryJoin []string `mapstructure:"retry_join"` // RetryMaxAttempts specifies the maximum number of times to retry joining a // host on startup. This is useful for cases where we know the node will be // online eventually. RetryMaxAttempts int `mapstructure:"retry_max"` // RetryInterval specifies the amount of time to wait in between join // attempts on agent start. The minimum allowed value is 1 second and // the default is 30s. RetryInterval time.Duration `mapstructure:"-" json:"-"` RetryIntervalRaw string `mapstructure:"retry_interval"` // RetryJoinEC2 configuration RetryJoinEC2 RetryJoinEC2 `mapstructure:"retry_join_ec2"` // RetryJoinWan is a list of addresses to join -wan with retry enabled. RetryJoinWan []string `mapstructure:"retry_join_wan"` // RetryMaxAttemptsWan specifies the maximum number of times to retry joining a // -wan host on startup. This is useful for cases where we know the node will be // online eventually. RetryMaxAttemptsWan int `mapstructure:"retry_max_wan"` // RetryIntervalWan specifies the amount of time to wait in between join // -wan attempts on agent start. The minimum allowed value is 1 second and // the default is 30s. RetryIntervalWan time.Duration `mapstructure:"-" json:"-"` RetryIntervalWanRaw string `mapstructure:"retry_interval_wan"` // ReconnectTimeout* specify the amount of time to wait to reconnect with // another agent before deciding it's permanently gone. This can be used to // control the time it takes to reap failed nodes from the cluster. ReconnectTimeoutLan time.Duration `mapstructure:"-"` ReconnectTimeoutLanRaw string `mapstructure:"reconnect_timeout"` ReconnectTimeoutWan time.Duration `mapstructure:"-"` ReconnectTimeoutWanRaw string `mapstructure:"reconnect_timeout_wan"` // EnableUi enables the statically-compiled assets for the Consul web UI and // serves them at the default /ui/ endpoint automatically. EnableUi bool `mapstructure:"ui"` // UiDir is the directory containing the Web UI resources. // If provided, the UI endpoints will be enabled. UiDir string `mapstructure:"ui_dir"` // PidFile is the file to store our PID in PidFile string `mapstructure:"pid_file"` // EnableSyslog is used to also tee all the logs over to syslog. Only supported // on linux and OSX. Other platforms will generate an error. EnableSyslog bool `mapstructure:"enable_syslog"` // SyslogFacility is used to control where the syslog messages go // By default, goes to LOCAL0 SyslogFacility string `mapstructure:"syslog_facility"` // RejoinAfterLeave controls our interaction with the cluster after leave. // When set to false (default), a leave causes 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 `mapstructure:"rejoin_after_leave"` // CheckUpdateInterval controls the interval on which the output of a health check // is updated if there is no change to the state. For example, a check in a steady // state may run every 5 second generating a unique output (timestamp, etc), forcing // constant writes. This allows Consul to defer the write for some period of time, // reducing the write pressure when the state is steady. CheckUpdateInterval time.Duration `mapstructure:"-"` CheckUpdateIntervalRaw string `mapstructure:"check_update_interval" json:"-"` // CheckReapInterval controls the interval on which we will look for // failed checks and reap their associated services, if so configured. CheckReapInterval time.Duration `mapstructure:"-"` // CheckDeregisterIntervalMin is the smallest allowed interval to set // a check's DeregisterCriticalServiceAfter value to. CheckDeregisterIntervalMin time.Duration `mapstructure:"-"` // ACLToken is the default token used to make requests if a per-request // token is not provided. If not configured the 'anonymous' token is used. ACLToken string `mapstructure:"acl_token" json:"-"` // ACLAgentMasterToken is a special token that has full read and write // privileges for this agent, and can be used to call agent endpoints // when no servers are available. ACLAgentMasterToken string `mapstructure:"acl_agent_master_token" json:"-"` // 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 'acl_token' will be used. ACLAgentToken string `mapstructure:"acl_agent_token" json:"-"` // 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 `mapstructure:"acl_master_token" json:"-"` // ACLDatacenter is the central datacenter that holds authoritative // ACL records. This must be the same for the entire cluster. // If this is not set, ACLs are not enabled. Off by default. ACLDatacenter string `mapstructure:"acl_datacenter"` // ACLTTL is used to control the time-to-live of cached ACLs . This has // a major impact on performance. By default, it is set to 30 seconds. ACLTTL time.Duration `mapstructure:"-"` ACLTTLRaw string `mapstructure:"acl_ttl"` // 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 `mapstructure:"acl_default_policy"` // ACLDisabledTTL is used by clients to determine how long they will // wait to check again with the servers if they discover ACLs are not // enabled. ACLDisabledTTL time.Duration `mapstructure:"-"` // ACLDownPolicy is used to control the ACL interaction when we cannot // reach the ACLDatacenter and the token is not in the cache. // There are two modes: // * allow - Allow all requests // * deny - Deny all requests // * extend-cache - Ignore the cache expiration, and allow cached // ACL's to be used to service requests. This // is the default. If the ACL is not in the cache, // this acts like deny. ACLDownPolicy string `mapstructure:"acl_down_policy"` // 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 `mapstructure:"acl_replication_token" json:"-"` // 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 `mapstructure:"acl_enforce_version_8"` // Watches are used to monitor various endpoints and to invoke a // handler to act appropriately. These are managed entirely in the // agent layer using the standard APIs. Watches []map[string]interface{} `mapstructure:"watches"` // DisableRemoteExec is used to turn off the remote execution // feature. This is for security to prevent unknown scripts from running. DisableRemoteExec bool `mapstructure:"disable_remote_exec"` // DisableUpdateCheck is used to turn off the automatic update and // security bulletin checking. DisableUpdateCheck bool `mapstructure:"disable_update_check"` // DisableAnonymousSignature is used to turn off the anonymous signature // send with the update check. This is used to deduplicate messages. DisableAnonymousSignature bool `mapstructure:"disable_anonymous_signature"` // HTTPAPIResponseHeaders are used to add HTTP header response fields to the HTTP API responses. HTTPAPIResponseHeaders map[string]string `mapstructure:"http_api_response_headers"` // AtlasInfrastructure is the name of the infrastructure we belong to. e.g. hashicorp/stage AtlasInfrastructure string `mapstructure:"atlas_infrastructure"` // AtlasToken is our authentication token from Atlas AtlasToken string `mapstructure:"atlas_token" json:"-"` // AtlasACLToken is applied to inbound requests if no other token // is provided. This takes higher precedence than the ACLToken. // Without this, the ACLToken is used. If that is not specified either, // then the 'anonymous' token is used. This can be set to 'anonymous' // to reduce the Atlas privileges to below that of the ACLToken. AtlasACLToken string `mapstructure:"atlas_acl_token" json:"-"` // AtlasJoin controls if Atlas will attempt to auto-join the node // to it's cluster. Requires Atlas integration. AtlasJoin bool `mapstructure:"atlas_join"` // AtlasEndpoint is the SCADA endpoint used for Atlas integration. If // empty, the defaults from the provider are used. AtlasEndpoint string `mapstructure:"atlas_endpoint"` // AEInterval controls the anti-entropy interval. This is how often // the agent attempts to reconcile its local state with the server's // representation of our state. Defaults to every 60s. AEInterval time.Duration `mapstructure:"-" json:"-"` // DisableCoordinates controls features related to network coordinates. DisableCoordinates bool `mapstructure:"disable_coordinates"` // SyncCoordinateRateTarget controls the rate for sending network // coordinates to the server, in updates per second. This is the max rate // that the server supports, so we scale our interval based on the size // of the cluster to try to achieve this in aggregate at the server. SyncCoordinateRateTarget float64 `mapstructure:"-" json:"-"` // SyncCoordinateIntervalMin sets the minimum interval that coordinates // will be sent to the server. We scale the interval based on the cluster // size, but below a certain interval it doesn't make sense send them any // faster. SyncCoordinateIntervalMin time.Duration `mapstructure:"-" json:"-"` // Checks holds the provided check definitions Checks []*CheckDefinition `mapstructure:"-" json:"-"` // Services holds the provided service definitions Services []*ServiceDefinition `mapstructure:"-" json:"-"` // ConsulConfig can either be provided or a default one created ConsulConfig *consul.Config `mapstructure:"-" json:"-"` // Revision is the GitCommit this maps to Revision string `mapstructure:"-"` // Version is the release version number Version string `mapstructure:"-"` // VersionPrerelease is a label for pre-release builds VersionPrerelease string `mapstructure:"-"` // WatchPlans contains the compiled watches WatchPlans []*watch.WatchPlan `mapstructure:"-" json:"-"` // UnixSockets is a map of socket configuration data UnixSockets UnixSocketConfig `mapstructure:"unix_sockets"` // Minimum Session TTL SessionTTLMin time.Duration `mapstructure:"-"` SessionTTLMinRaw string `mapstructure:"session_ttl_min"` }
Config is the configuration that can be set for an Agent. Some of this is configurable as CLI flags, but most must be set using a configuration file.
func DecodeConfig ¶
DecodeConfig reads the configuration from the given reader in JSON format and decodes it into a proper Config structure.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is used to return a sane default configuration
func DevConfig ¶ added in v0.6.1
func DevConfig() *Config
DevConfig is used to return a set of configuration to use for dev mode.
func MergeConfig ¶
MergeConfig merges two configurations together to make a single new configuration.
func ReadConfigPaths ¶
ReadConfigPaths reads the paths in the given order to load configurations. The paths can be to files or directories. If the path is a directory, we read one directory deep and read any files ending in ".json" as configuration files.
func (*Config) ClientListener ¶
ClientListener is used to format a listener for a port on a ClientAddr
func (*Config) EncryptBytes ¶
EncryptBytes returns the encryption key configured.
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.
type CriticalCheck ¶ added in v0.7.0
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 DNSConfig ¶ added in v0.3.0
type DNSConfig struct { // NodeTTL provides the TTL value for a node query NodeTTL time.Duration `mapstructure:"-"` NodeTTLRaw string `mapstructure:"node_ttl" json:"-"` // ServiceTTL provides the TTL value for a service // query for given service. The "*" wildcard can be used // to set a default for all services. ServiceTTL map[string]time.Duration `mapstructure:"-"` ServiceTTLRaw map[string]string `mapstructure:"service_ttl" json:"-"` // AllowStale is used to enable lookups with stale // data. This gives horizontal read scalability since // any Consul server can service the query instead of // only the leader. AllowStale *bool `mapstructure:"allow_stale"` // EnableTruncate is used to enable setting the truncate // flag for UDP DNS queries. This allows unmodified // clients to re-query the consul server using TCP // when the total number of records exceeds the number // returned by default for UDP. EnableTruncate bool `mapstructure:"enable_truncate"` // UDPAnswerLimit is used to limit the maximum number of DNS Resource // Records returned in the ANSWER section of a DNS response. This is // not normally useful and will be limited based on the querying // protocol, however systems that implemented §6 Rule 9 in RFC3484 // may want to set this to `1` in order to subvert §6 Rule 9 and // re-obtain the effect of randomized resource records (i.e. each // answer contains only one IP, but the IP changes every request). // RFC3484 sorts answers in a deterministic order, which defeats the // purpose of randomized DNS responses. This RFC has been obsoleted // by RFC6724 and restores the desired behavior of randomized // responses, however a large number of Linux hosts using glibc(3) // implemented §6 Rule 9 and may need this option (e.g. CentOS 5-6, // Debian Squeeze, etc). UDPAnswerLimit int `mapstructure:"udp_answer_limit"` // MaxStale is used to bound how stale of a result is // accepted for a DNS lookup. This can be used with // AllowStale to limit how old of a value is served up. // If the stale result exceeds this, another non-stale // stale read is performed. MaxStale time.Duration `mapstructure:"-"` MaxStaleRaw string `mapstructure:"max_stale" json:"-"` // OnlyPassing is used to determine whether to filter nodes // whose health checks are in any non-passing state. By // default, only nodes in a critical state are excluded. OnlyPassing bool `mapstructure:"only_passing"` // DisableCompression is used to control whether DNS responses are // compressed. In Consul 0.7 this was turned on by default and this // config was added as an opt-out. DisableCompression bool `mapstructure:"disable_compression"` // RecursorTimeout specifies the timeout in seconds // for Consul's internal dns client used for recursion. // This value is used for the connection, read and write timeout. // Default: 2s RecursorTimeout time.Duration `mapstructure:"-"` RecursorTimeoutRaw string `mapstructure:"recursor_timeout" json:"-"` }
DNSConfig is used to fine tune the DNS sub-system. It can be used to control cache values, and stale reads
type DNSServer ¶
type DNSServer struct {
// contains filtered or unexported fields
}
DNSServer is used to wrap an Agent and expose various service discovery endpoints using a DNS interface.
type DockerClient ¶ added in v0.6.0
type DockerClient interface { CreateExec(docker.CreateExecOptions) (*docker.Exec, error) StartExec(string, docker.StartExecOptions) error InspectExec(string) (*docker.ExecInspect, error) }
A custom interface since go-dockerclient doesn't have one We will use this interface in our test to inject a fake client
type FilePermissions ¶ added in v0.5.0
type FilePermissions interface { // User returns a user ID or user name User() string // Group returns a group ID. Group names are not supported. Group() string // Mode returns a string of file mode bits e.g. "0644" Mode() string }
FilePermissions is an interface which allows a struct to set ownership and permissions easily on a file it describes.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is used to wrap an Agent and expose various API's in a RESTful manner
func NewHTTPServers ¶ added in v0.5.0
NewHTTPServers starts new HTTP servers to provide an interface to the agent.
func (*HTTPServer) ACLClone ¶ added in v0.4.0
func (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLCreate ¶ added in v0.4.0
func (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLDestroy ¶ added in v0.4.0
func (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLGet ¶ added in v0.4.0
func (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLList ¶ added in v0.4.0
func (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLReplicationStatus ¶ added in v0.7.0
func (s *HTTPServer) ACLReplicationStatus(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) ACLUpdate ¶ added in v0.4.0
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 ¶ added in v0.6.4
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 ¶ added in v0.7.2
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) AgentMonitor ¶ added in v0.7.2
func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentNodeMaintenance ¶ added in v0.5.0
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 ¶ added in v0.7.2
func (s *HTTPServer) AgentReload(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentSelf ¶ added in v0.3.0
func (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (interface{}, error)
func (*HTTPServer) AgentServiceMaintenance ¶ added in v0.5.0
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) 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 ¶ added in v0.6.0
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 ¶ added in v0.6.0
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 ¶ added in v0.4.0
func (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error)
EventFire is used to fire a new event
func (*HTTPServer) EventList ¶ added in v0.4.0
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 ¶ added in v0.6.4
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 ¶ added in v0.2.0
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 ¶ added in v0.7.2
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 ¶ added in v0.7.2
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 ¶ added in v0.7.2
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 ¶ added in v0.7.2
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) OperatorKeyringEndpoint ¶ added in v0.7.2
func (s *HTTPServer) OperatorKeyringEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)
OperatorKeyringEndpoint handles keyring operations (install, list, use, remove)
func (*HTTPServer) OperatorRaftConfiguration ¶ added in v0.7.0
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 ¶ added in v0.7.0
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) PreparedQueryGeneral ¶ added in v0.6.0
func (s *HTTPServer) PreparedQueryGeneral(resp http.ResponseWriter, req *http.Request) (interface{}, error)
PreparedQueryGeneral handles all the general prepared query requests.
func (*HTTPServer) PreparedQuerySpecific ¶ added in v0.6.0
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 ¶ added in v0.3.0
func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionCreate is used to create a new session
func (*HTTPServer) SessionDestroy ¶ added in v0.3.0
func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionDestroy is used to destroy an existing session
func (*HTTPServer) SessionGet ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (s *HTTPServer) SessionList(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionList is used to list all the sessions
func (*HTTPServer) SessionRenew ¶ added in v0.5.0
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 ¶ added in v0.3.0
func (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error)
SessionsForNode returns all the nodes belonging to a node
func (*HTTPServer) Shutdown ¶
func (s *HTTPServer) Shutdown()
Shutdown is used to shutdown the HTTP server
func (*HTTPServer) Snapshot ¶ added in v0.7.1
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 ¶ added in v0.7.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 KeyringEntry ¶ added in v0.5.0
type KeyringInfo ¶ added in v0.5.0
type KeyringMessage ¶ added in v0.5.0
type Performance ¶ added in v0.7.0
type Performance struct { // RaftMultiplier is an integer multiplier used to scale Raft timing // parameters: HeartbeatTimeout, ElectionTimeout, and LeaderLeaseTimeout. RaftMultiplier uint `mapstructure:"raft_multiplier"` }
Performance is used to tune the performance of Consul's subsystems.
type PortConfig ¶
type PortConfig struct { DNS int // DNS Query interface HTTP int // HTTP API HTTPS int // HTTPS API RPC int // CLI RPC SerfLan int `mapstructure:"serf_lan"` // LAN gossip (Client + Server) SerfWan int `mapstructure:"serf_wan"` // WAN gossip (Server only) Server int // Server internal RPC }
Ports is used to simplify the configuration by providing default ports, and allowing the addresses to only be specified once
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient is the RPC client to make requests to the agent RPC.
func NewRPCClient ¶
NewRPCClient is used to create a new RPC client given the address. This will properly dial, handshake, and start listening
func (*RPCClient) ForceLeave ¶
ForceLeave is used to ask the agent to issue a leave command for a given node
func (*RPCClient) InstallKey ¶ added in v0.5.0
func (*RPCClient) LANMembers ¶
LANMembers is used to fetch a list of known members
func (*RPCClient) Stop ¶
func (c *RPCClient) Stop(handle StreamHandle) error
Stop is used to unsubscribe from logs or event streams
func (*RPCClient) WANMembers ¶
WANMembers is used to fetch a list of known members
type RetryJoinEC2 ¶ added in v0.7.1
type RetryJoinEC2 struct { // The AWS region to look for instances in Region string `mapstructure:"region"` // The tag key and value to use when filtering instances TagKey string `mapstructure:"tag_key"` TagValue string `mapstructure:"tag_value"` // The AWS credentials to use for making requests to EC2 AccessKeyID string `mapstructure:"access_key_id"` SecretAccessKey string `mapstructure:"secret_access_key"` }
RetryJoinEC2 is used to configure discovery of instances via Amazon's EC2 api
type ServiceDefinition ¶
type ServiceDefinition struct { ID string Name string Tags []string Address string Port int Check CheckType Checks CheckTypes Token string EnableTagOverride bool }
ServiceDefinition is used to JSON decode the Service definitions
func DecodeServiceDefinition ¶
func DecodeServiceDefinition(raw interface{}) (*ServiceDefinition, error)
DecodeServiceDefinition is used to decode a service definition
func (*ServiceDefinition) CheckTypes ¶ added in v0.5.0
func (s *ServiceDefinition) CheckTypes() (checks CheckTypes)
func (*ServiceDefinition) NodeService ¶
func (s *ServiceDefinition) NodeService() *structs.NodeService
type ServiceSummary ¶ added in v0.2.0
type ServiceSummary struct { Name string Nodes []string ChecksPassing int ChecksWarning int ChecksCritical int }
ServiceSummary is used to summarize a service
type StreamHandle ¶
type StreamHandle uint64
StreamHandle is an opaque handle passed to stop to stop streaming
type Telemetry ¶ added in v0.6.4
type Telemetry struct { // StatsiteAddr is the address of a statsite instance. If provided, // metrics will be streamed to that instance. StatsiteAddr string `mapstructure:"statsite_address"` // StatsdAddr is the address of a statsd instance. If provided, // metrics will be sent to that instance. StatsdAddr string `mapstructure:"statsd_address"` // StatsitePrefix is the prefix used to write stats values to. By // default this is set to 'consul'. StatsitePrefix string `mapstructure:"statsite_prefix"` // DisableHostname will disable hostname prefixing for all metrics DisableHostname bool `mapstructure:"disable_hostname"` // DogStatsdAddr is the address of a dogstatsd instance. If provided, // metrics will be sent to that instance DogStatsdAddr string `mapstructure:"dogstatsd_addr"` // DogStatsdTags are the global tags that should be sent with each packet to dogstatsd // It is a list of strings, where each string looks like "my_tag_name:my_tag_value" DogStatsdTags []string `mapstructure:"dogstatsd_tags"` // CirconusAPIToken is a valid API Token used to create/manage check. If provided, // metric management is enabled. // Default: none CirconusAPIToken string `mapstructure:"circonus_api_token" json:"-"` // CirconusAPIApp is an app name associated with API token. // Default: "consul" CirconusAPIApp string `mapstructure:"circonus_api_app"` // CirconusAPIURL is the base URL to use for contacting the Circonus API. // Default: "https://api.circonus.com/v2" CirconusAPIURL string `mapstructure:"circonus_api_url"` // CirconusSubmissionInterval is the interval at which metrics are submitted to Circonus. // Default: 10s CirconusSubmissionInterval string `mapstructure:"circonus_submission_interval"` // CirconusCheckSubmissionURL is the check.config.submission_url field from a // previously created HTTPTRAP check. // Default: none CirconusCheckSubmissionURL string `mapstructure:"circonus_submission_url"` // CirconusCheckID is the check id (not check bundle id) from a previously created // HTTPTRAP check. The numeric portion of the check._cid field. // Default: none CirconusCheckID string `mapstructure:"circonus_check_id"` // CirconusCheckForceMetricActivation will force enabling metrics, as they are encountered, // if the metric already exists and is NOT active. If check management is enabled, the default // behavior is to add new metrics as they are encoutered. If the metric already exists in the // check, it will *NOT* be activated. This setting overrides that behavior. // Default: "false" CirconusCheckForceMetricActivation string `mapstructure:"circonus_check_force_metric_activation"` // CirconusCheckInstanceID serves to uniquely identify the metrics coming from this "instance". // It can be used to maintain metric continuity with transient or ephemeral instances as // they move around within an infrastructure. // Default: hostname:app CirconusCheckInstanceID string `mapstructure:"circonus_check_instance_id"` // CirconusCheckSearchTag is a special tag which, when coupled with the instance id, helps to // narrow down the search results when neither a Submission URL or Check ID is provided. // Default: service:app (e.g. service:consul) CirconusCheckSearchTag string `mapstructure:"circonus_check_search_tag"` // CirconusCheckTags is a comma separated list of tags to apply to the check. Note that // the value of CirconusCheckSearchTag will always be added to the check. // Default: none CirconusCheckTags string `mapstructure:"circonus_check_tags"` // CirconusCheckDisplayName is the name for the check which will be displayed in the Circonus UI. // Default: value of CirconusCheckInstanceID CirconusCheckDisplayName string `mapstructure:"circonus_check_display_name"` // CirconusBrokerID is an explicit broker to use when creating a new check. The numeric portion // of broker._cid. If metric management is enabled and neither a Submission URL nor Check ID // is provided, an attempt will be made to search for an existing check using Instance ID and // Search Tag. If one is not found, a new HTTPTRAP check will be created. // Default: use Select Tag if provided, otherwise, a random Enterprise Broker associated // with the specified API token or the default Circonus Broker. // Default: none CirconusBrokerID string `mapstructure:"circonus_broker_id"` // CirconusBrokerSelectTag is a special tag which will be used to select a broker when // a Broker ID is not provided. The best use of this is to as a hint for which broker // should be used based on *where* this particular instance is running. // (e.g. a specific geo location or datacenter, dc:sfo) // Default: none CirconusBrokerSelectTag string `mapstructure:"circonus_broker_select_tag"` }
Telemetry is the telemetry configuration for the server
type UnixSocketConfig ¶ added in v0.5.0
type UnixSocketConfig struct {
UnixSocketPermissions `mapstructure:",squash"`
}
UnixSocketConfig stores information about various unix sockets which Consul creates and uses for communication.
type UnixSocketPermissions ¶ added in v0.5.0
type UnixSocketPermissions struct { Usr string `mapstructure:"user"` Grp string `mapstructure:"group"` Perms string `mapstructure:"mode"` }
UnixSocketPermissions contains information about a unix socket, and implements the FilePermissions interface.
func (UnixSocketPermissions) Group ¶ added in v0.5.0
func (u UnixSocketPermissions) Group() string
func (UnixSocketPermissions) Mode ¶ added in v0.5.0
func (u UnixSocketPermissions) Mode() string
func (UnixSocketPermissions) User ¶ added in v0.5.0
func (u UnixSocketPermissions) User() string
type UserEvent ¶ added in v0.4.0
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
- catalog_endpoint.go
- check.go
- command.go
- config.go
- coordinate_endpoint.go
- dns.go
- event_endpoint.go
- flag_slice_value.go
- health_endpoint.go
- http.go
- keyring.go
- kvs_endpoint.go
- local.go
- operator_endpoint.go
- prepared_query_endpoint.go
- remote_exec.go
- rpc.go
- rpc_client.go
- rpc_log_stream.go
- session_endpoint.go
- snapshot_endpoint.go
- status_endpoint.go
- structs.go
- translate_addr.go
- txn_endpoint.go
- ui_endpoint.go
- user_event.go
- util.go
- watch_handler.go