{"modulePath":"github.com/stackdocker/consul","version":"v0.5.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package agent\n\n## Constants\n\n```go\nconst (\n\t// Do not allow for a interval below this value.\n\t// Otherwise we risk fork bombing a system.\n\tMinInterval = time.Second\n\n\t// Limit the size of a check's output to the\n\t// last CheckBufSize. Prevents an enormous buffer\n\t// from being captured\n\tCheckBufSize = 4 * 1024 // 4KB\n\n\t// Use this user agent when doing requests for\n\t// HTTP health checks.\n\tHttpUserAgent = \"Consul Health Check\"\n)\n```\n\n```go\nconst (\n\tMinRPCVersion = 1\n\tMaxRPCVersion = 1\n)\n```\n\n```go\nconst (\n\t// Limit the size of a watch handlers's output to the\n\t// last WatchBufSize. Prevents an enormous buffer\n\t// from being captured\n\tWatchBufSize = 4 * 1024 // 4KB\n)\n```\n\n## Functions\n\n```go\nfunc ExecScript(script string) (*exec.Cmd, error)\n```\nExecScript returns a command to execute a script\n\n```go\nfunc FixupCheckType(raw interface{}) error\n```\n\n```go\nfunc FixupLockDelay(raw interface{}) error\n```\nFixupLockDelay is used to handle parsing the JSON body to session/create and properly parsing out the lock delay duration value.\n\n```go\nfunc LevelFilter() *logutils.LevelFilter\n```\nLevelFilter returns a LevelFilter that is configured with the log levels that we use.\n\n```go\nfunc NewLogWriter(buf int) *logWriter\n```\nNewLogWriter creates a logWriter with the given buffer capacity\n\n```go\nfunc NewProvider(c *Config, logOutput io.Writer) (*client.Provider, net.Listener, error)\n```\nNewProvider creates a new SCADA provider using the given configuration. Requests for the HTTP capability are passed off to the listener that is returned.\n\n```go\nfunc ProviderConfig(c *Config) *client.ProviderConfig\n```\nProviderConfig returns the configuration for the SCADA provider\n\n```go\nfunc ProviderService(c *Config) *client.ProviderService\n```\nProviderService returns the service information for the provider\n\n```go\nfunc ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool\n```\nValidateLevelFilter verifies that the log levels within the filter are valid.\n\n## Types\n\n```go\ntype AddressConfig struct {\n\tDNS   string // DNS Query interface\n\tHTTP  string // HTTP API\n\tHTTPS string // HTTPS API\n\tRPC   string // CLI RPC\n}\n```\nAddressConfig is used to provide address overrides for specific services. By default, either ClientAddress or ServerAddress is used.\n\n```go\ntype Agent struct {\n\t// contains filtered or unexported fields\n}\n```\nThe 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.\n\n```go\nfunc Create(config *Config, logOutput io.Writer) (*Agent, error)\n```\nCreate is used to create a new Agent. Returns the agent or potentially an error.\n\n```go\nfunc (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist bool, token string) error\n```\nAddCheck 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\n\n```go\nfunc (a *Agent) AddService(service *structs.NodeService, chkTypes CheckTypes, persist bool, token string) error\n```\nAddService is used to add a service entry. This entry is persistent and the agent will make a best effort to ensure it is registered\n\n```go\nfunc (a *Agent) DisableNodeMaintenance()\n```\nDisableNodeMaintenance removes a node from maintenance mode\n\n```go\nfunc (a *Agent) DisableServiceMaintenance(serviceID string) error\n```\nDisableServiceMaintenance will deregister the fake maintenance mode check if the service has been marked as in maintenance.\n\n```go\nfunc (a *Agent) EnableNodeMaintenance(reason string)\n```\nEnableNodeMaintenance places a node into maintenance mode.\n\n```go\nfunc (a *Agent) EnableServiceMaintenance(serviceID, reason string) error\n```\nEnableServiceMaintenance will register a false health check against the given service ID with critical status. This will exclude the service from queries.\n\n```go\nfunc (a *Agent) ForceLeave(node string) (err error)\n```\nForceLeave is used to remove a failed node from the cluster\n\n```go\nfunc (a *Agent) InstallKey(key string) (*structs.KeyringResponses, error)\n```\nInstallKey installs a new gossip encryption key\n\n```go\nfunc (a *Agent) JoinLAN(addrs []string) (n int, err error)\n```\nJoinLAN is used to have the agent join a LAN cluster\n\n```go\nfunc (a *Agent) JoinWAN(addrs []string) (n int, err error)\n```\nJoinWAN is used to have the agent join a WAN cluster\n\n```go\nfunc (a *Agent) LANMembers() []serf.Member\n```\nLANMembers is used to retrieve the LAN members\n\n```go\nfunc (a *Agent) LastUserEvent() *UserEvent\n```\nLastUserEvent is used to return the lastest user event. This will return nil if there is no recent event.\n\n```go\nfunc (a *Agent) Leave() error\n```\nLeave is used to prepare the agent for a graceful shutdown\n\n```go\nfunc (a *Agent) ListKeys() (*structs.KeyringResponses, error)\n```\nListKeys lists out all keys installed on the collective Consul cluster. This includes both servers and clients in all DC's.\n\n```go\nfunc (a *Agent) LocalMember() serf.Member\n```\nLocalMember is used to return the local node\n\n```go\nfunc (a *Agent) PauseSync()\n```\nPauseSync is used to pause anti-entropy while bulk changes are make\n\n```go\nfunc (a *Agent) RPC(method string, args interface{}, reply interface{}) error\n```\nRPC is used to make an RPC call to the Consul servers This allows the agent to implement the Consul.Interface\n\n```go\nfunc (a *Agent) RemoveCheck(checkID string, persist bool) error\n```\nRemoveCheck is used to remove a health check. The agent will make a best effort to ensure it is deregistered\n\n```go\nfunc (a *Agent) RemoveKey(key string) (*structs.KeyringResponses, error)\n```\nRemoveKey will remove a gossip encryption key from the keyring\n\n```go\nfunc (a *Agent) RemoveService(serviceID string, persist bool) error\n```\nRemoveService is used to remove a service entry. The agent will make a best effort to ensure it is deregistered\n\n```go\nfunc (a *Agent) ResumeSync()\n```\nResumeSync is used to unpause anti-entropy after bulk changes are make\n\n```go\nfunc (a *Agent) Shutdown() error\n```\nShutdown is used to hard stop the agent. Should be preceded by a call to Leave to do it gracefully.\n\n```go\nfunc (a *Agent) ShutdownCh() \u003c-chan struct{}\n```\nShutdownCh is used to return a channel that can be selected to wait for the agent to perform a shutdown.\n\n```go\nfunc (a *Agent) StartSync()\n```\nStartSync is called once Services and Checks are registered. This is called to prevent a race between clients and the anti-entropy routines\n\n```go\nfunc (a *Agent) Stats() map[string]map[string]string\n```\nStats is used to get various debugging state from the sub-systems\n\n```go\nfunc (a *Agent) UpdateCheck(checkID, status, output string) error\n```\nUpdateCheck is used to update the status of a check. This can only be used with checks of the TTL type.\n\n```go\nfunc (a *Agent) UseKey(key string) (*structs.KeyringResponses, error)\n```\nUseKey changes the primary encryption key used to encrypt messages\n\n```go\nfunc (a *Agent) UserEvent(dc string, params *UserEvent) error\n```\nUserEvent is used to fire an event via the Serf layer on the LAN\n\n```go\nfunc (a *Agent) UserEvents() []*UserEvent\n```\nUserEvents is used to return a slice of the most recent user events.\n\n```go\nfunc (a *Agent) WANMembers() []serf.Member\n```\nWANMembers is used to retrieve the WAN members\n\n```go\ntype AgentRPC struct {\n\tsync.Mutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAgentRPC(agent *Agent, listener net.Listener,\n\tlogOutput io.Writer, logWriter *logWriter) *AgentRPC\n```\nNewAgentRPC is used to create a new Agent RPC handler\n\n```go\nfunc (i *AgentRPC) ReloadCh() \u003c-chan struct{}\n```\nReloadCh returns a channel that can be watched for when a reload is being triggered.\n\n```go\nfunc (i *AgentRPC) Shutdown()\n```\nShutdown is used to shutdown the RPC layer\n\n```go\ntype AgentSelf struct {\n\tConfig *Config\n\tMember serf.Member\n}\n```\n\n```go\ntype AppendSliceValue []string\n```\nAppendSliceValue implements the flag.Value interface and allows multiple calls to the same variable to append a list.\n\n```go\nfunc (s *AppendSliceValue) Set(value string) error\n```\n\n```go\nfunc (s *AppendSliceValue) String() string\n```\n\n```go\ntype CheckDefinition struct {\n\tID        string\n\tName      string\n\tNotes     string\n\tServiceID string\n\tToken     string\n\tStatus    string\n\tCheckType `mapstructure:\",squash\"`\n}\n```\nChecKDefinition is used to JSON decode the Check definitions\n\n```go\nfunc DecodeCheckDefinition(raw interface{}) (*CheckDefinition, error)\n```\nDecodeCheckDefinition is used to decode a check definition\n\n```go\nfunc (c *CheckDefinition) HealthCheck(node string) *structs.HealthCheck\n```\n\n```go\ntype CheckHTTP struct {\n\tNotify   CheckNotifier\n\tCheckID  string\n\tHTTP     string\n\tInterval time.Duration\n\tTimeout  time.Duration\n\tLogger   *log.Logger\n\t// contains filtered or unexported fields\n}\n```\nCheckHTTP 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\n\n```go\nfunc (c *CheckHTTP) Start()\n```\nStart is used to start an HTTP check. The check runs until stop is called\n\n```go\nfunc (c *CheckHTTP) Stop()\n```\nStop is used to stop an HTTP check.\n\n```go\ntype CheckMonitor struct {\n\tNotify   CheckNotifier\n\tCheckID  string\n\tScript   string\n\tInterval time.Duration\n\tLogger   *log.Logger\n\t// contains filtered or unexported fields\n}\n```\nCheckMonitor 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.\n\n```go\nfunc (c *CheckMonitor) Start()\n```\nStart is used to start a check monitor. Monitor runs until stop is called\n\n```go\nfunc (c *CheckMonitor) Stop()\n```\nStop is used to stop a check monitor.\n\n```go\ntype CheckNotifier interface {\n\tUpdateCheck(checkID, status, output string)\n}\n```\nCheckNotifier interface is used by the CheckMonitor to notify when a check has a status update. The update should take care to be idempotent.\n\n```go\ntype CheckTTL struct {\n\tNotify  CheckNotifier\n\tCheckID string\n\tTTL     time.Duration\n\tLogger  *log.Logger\n\t// contains filtered or unexported fields\n}\n```\nCheckTTL 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.\n\n```go\nfunc (c *CheckTTL) SetStatus(status, output string)\n```\nSetStatus is used to update the status of the check, and to renew the TTL. If expired, TTL is restarted.\n\n```go\nfunc (c *CheckTTL) Start()\n```\nStart is used to start a check ttl, runs until Stop()\n\n```go\nfunc (c *CheckTTL) Stop()\n```\nStop is used to stop a check ttl.\n\n```go\ntype CheckType struct {\n\tScript   string\n\tHTTP     string\n\tInterval time.Duration\n\n\tTimeout time.Duration\n\tTTL     time.Duration\n\n\tStatus string\n\n\tNotes string\n}\n```\nCheckType is used to create either the CheckMonitor or the CheckTTL. Three types are supported: Script, HTTP, and TTL Script and HTTP both require Interval Only one of the types needs to be provided\n\n\tTTL or Script/Interval or HTTP/Interval\n\n```go\nfunc (c *CheckType) IsHTTP() bool\n```\nIsHTTP checks if this is a HTTP type\n\n```go\nfunc (c *CheckType) IsMonitor() bool\n```\nIsMonitor checks if this is a Monitor type\n\n```go\nfunc (c *CheckType) IsTTL() bool\n```\nIsTTL checks if this is a TTL type\n\n```go\nfunc (c *CheckType) Valid() bool\n```\nValid checks if the CheckType is valid\n\n```go\ntype CheckTypes []*CheckType\n```\n\n```go\ntype Command struct {\n\tRevision          string\n\tVersion           string\n\tVersionPrerelease string\n\tUi                cli.Ui\n\tShutdownCh        \u003c-chan struct{}\n\t// contains filtered or unexported fields\n}\n```\nCommand 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.\n\n```go\nfunc (c *Command) Help() string\n```\n\n```go\nfunc (c *Command) Run(args []string) int\n```\n\n```go\nfunc (c *Command) Synopsis() string\n```\n\n```go\ntype Config struct {\n\t// Bootstrap is used to bring up the first Consul server, and\n\t// permits that node to elect itself leader\n\tBootstrap bool `mapstructure:\"bootstrap\"`\n\n\t// BootstrapExpect tries to automatically bootstrap the Consul cluster,\n\t// by witholding peers until enough servers join.\n\tBootstrapExpect int `mapstructure:\"bootstrap_expect\"`\n\n\t// Server controls if this agent acts like a Consul server,\n\t// or merely as a client. Servers have more state, take part\n\t// in leader election, etc.\n\tServer bool `mapstructure:\"server\"`\n\n\t// Datacenter is the datacenter this node is in. Defaults to dc1\n\tDatacenter string `mapstructure:\"datacenter\"`\n\n\t// DataDir is the directory to store our state in\n\tDataDir string `mapstructure:\"data_dir\"`\n\n\t// DNSRecursors can be set to allow the DNS servers to recursively\n\t// resolve non-consul domains. It is deprecated, and merges into the\n\t// recursors array.\n\tDNSRecursor string `mapstructure:\"recursor\"`\n\n\t// DNSRecursors can be set to allow the DNS servers to recursively\n\t// resolve non-consul domains\n\tDNSRecursors []string `mapstructure:\"recursors\"`\n\n\t// DNS configuration\n\tDNSConfig DNSConfig `mapstructure:\"dns_config\"`\n\n\t// Domain is the DNS domain for the records. Defaults to \"consul.\"\n\tDomain string `mapstructure:\"domain\"`\n\n\t// Encryption key to use for the Serf communication\n\tEncryptKey string `mapstructure:\"encrypt\" json:\"-\"`\n\n\t// LogLevel is the level of the logs to putout\n\tLogLevel string `mapstructure:\"log_level\"`\n\n\t// Node name is the name we use to advertise. Defaults to hostname.\n\tNodeName string `mapstructure:\"node_name\"`\n\n\t// ClientAddr is used to control the address we bind to for\n\t// client services (DNS, HTTP, HTTPS, RPC)\n\tClientAddr string `mapstructure:\"client_addr\"`\n\n\t// BindAddr is used to control the address we bind to.\n\t// If not specified, the first private IP we find is used.\n\t// This controls the address we use for cluster facing\n\t// services (Gossip, Server RPC)\n\tBindAddr string `mapstructure:\"bind_addr\"`\n\n\t// AdvertiseAddr is the address we use for advertising our Serf,\n\t// and Consul RPC IP. If not specified, bind address is used.\n\tAdvertiseAddr string `mapstructure:\"advertise_addr\"`\n\n\t// AdvertiseAddrWan is the address we use for advertising our\n\t// Serf WAN IP. If not specified, the general advertise address is used.\n\tAdvertiseAddrWan string `mapstructure:\"advertise_addr_wan\"`\n\n\t// Port configurations\n\tPorts PortConfig\n\n\t// Address configurations\n\tAddresses AddressConfig\n\n\t// LeaveOnTerm controls if Serf does a graceful leave when receiving\n\t// the TERM signal. Defaults false. This can be changed on reload.\n\tLeaveOnTerm bool `mapstructure:\"leave_on_terminate\"`\n\n\t// SkipLeaveOnInt controls if Serf skips a graceful leave when receiving\n\t// the INT signal. Defaults false. This can be changed on reload.\n\tSkipLeaveOnInt bool `mapstructure:\"skip_leave_on_interrupt\"`\n\n\t// StatsiteAddr is the address of a statsite instance. If provided,\n\t// metrics will be streamed to that instance.\n\tStatsiteAddr string `mapstructure:\"statsite_addr\"`\n\n\t// StatsitePrefix is the prefix used to write stats values to. By\n\t// default this is set to 'consul'.\n\tStatsitePrefix string `mapstructure:\"statsite_prefix\"`\n\n\t// StatsdAddr is the address of a statsd instance. If provided,\n\t// metrics will be sent to that instance.\n\tStatsdAddr string `mapstructure:\"statsd_addr\"`\n\n\t// Protocol is the Consul protocol version to use.\n\tProtocol int `mapstructure:\"protocol\"`\n\n\t// EnableDebug is used to enable various debugging features\n\tEnableDebug bool `mapstructure:\"enable_debug\"`\n\n\t// VerifyIncoming is used to verify the authenticity of incoming connections.\n\t// This means that TCP requests are forbidden, only allowing for TLS. TLS connections\n\t// must match a provided certificate authority. This can be used to force client auth.\n\tVerifyIncoming bool `mapstructure:\"verify_incoming\"`\n\n\t// VerifyOutgoing is used to verify the authenticity of outgoing connections.\n\t// This means that TLS requests are used. TLS connections must match a provided\n\t// certificate authority. This is used to verify authenticity of server nodes.\n\tVerifyOutgoing bool `mapstructure:\"verify_outgoing\"`\n\n\t// VerifyServerHostname is used to enable hostname verification of servers. This\n\t// ensures that the certificate presented is valid for server.\u003cdatacenter\u003e.\u003cdomain\u003e.\n\t// This prevents a compromised client from being restarted as a server, and then\n\t// intercepting request traffic as well as being added as a raft peer. This should be\n\t// enabled by default with VerifyOutgoing, but for legacy reasons we cannot break\n\t// existing clients.\n\tVerifyServerHostname bool `mapstructure:\"verify_server_hostname\"`\n\n\t// CAFile is a path to a certificate authority file. This is used with VerifyIncoming\n\t// or VerifyOutgoing to verify the TLS connection.\n\tCAFile string `mapstructure:\"ca_file\"`\n\n\t// CertFile is used to provide a TLS certificate that is used for serving TLS connections.\n\t// Must be provided to serve TLS connections.\n\tCertFile string `mapstructure:\"cert_file\"`\n\n\t// KeyFile is used to provide a TLS key that is used for serving TLS connections.\n\t// Must be provided to serve TLS connections.\n\tKeyFile string `mapstructure:\"key_file\"`\n\n\t// ServerName is used with the TLS certificates to ensure the name we\n\t// provid ematches the certificate\n\tServerName string `mapstructure:\"server_name\"`\n\n\t// StartJoin is a list of addresses to attempt to join when the\n\t// agent starts. If Serf is unable to communicate with any of these\n\t// addresses, then the agent will error and exit.\n\tStartJoin []string `mapstructure:\"start_join\"`\n\n\t// StartJoinWan is a list of addresses to attempt to join -wan when the\n\t// agent starts. If Serf is unable to communicate with any of these\n\t// addresses, then the agent will error and exit.\n\tStartJoinWan []string `mapstructure:\"start_join_wan\"`\n\n\t// RetryJoin is a list of addresses to join with retry enabled.\n\tRetryJoin []string `mapstructure:\"retry_join\"`\n\n\t// RetryMaxAttempts specifies the maximum number of times to retry joining a\n\t// host on startup. This is useful for cases where we know the node will be\n\t// online eventually.\n\tRetryMaxAttempts int `mapstructure:\"retry_max\"`\n\n\t// RetryInterval specifies the amount of time to wait in between join\n\t// attempts on agent start. The minimum allowed value is 1 second and\n\t// the default is 30s.\n\tRetryInterval    time.Duration `mapstructure:\"-\" json:\"-\"`\n\tRetryIntervalRaw string        `mapstructure:\"retry_interval\"`\n\n\t// RetryJoinWan is a list of addresses to join -wan with retry enabled.\n\tRetryJoinWan []string `mapstructure:\"retry_join_wan\"`\n\n\t// RetryMaxAttemptsWan specifies the maximum number of times to retry joining a\n\t// -wan host on startup. This is useful for cases where we know the node will be\n\t// online eventually.\n\tRetryMaxAttemptsWan int `mapstructure:\"retry_max_wan\"`\n\n\t// RetryIntervalWan specifies the amount of time to wait in between join\n\t// -wan attempts on agent start. The minimum allowed value is 1 second and\n\t// the default is 30s.\n\tRetryIntervalWan    time.Duration `mapstructure:\"-\" json:\"-\"`\n\tRetryIntervalWanRaw string        `mapstructure:\"retry_interval_wan\"`\n\n\t// UiDir is the directory containing the Web UI resources.\n\t// If provided, the UI endpoints will be enabled.\n\tUiDir string `mapstructure:\"ui_dir\"`\n\n\t// PidFile is the file to store our PID in\n\tPidFile string `mapstructure:\"pid_file\"`\n\n\t// EnableSyslog is used to also tee all the logs over to syslog. Only supported\n\t// on linux and OSX. Other platforms will generate an error.\n\tEnableSyslog bool `mapstructure:\"enable_syslog\"`\n\n\t// SyslogFacility is used to control where the syslog messages go\n\t// By default, goes to LOCAL0\n\tSyslogFacility string `mapstructure:\"syslog_facility\"`\n\n\t// RejoinAfterLeave controls our interaction with the cluster after leave.\n\t// When set to false (default), a leave causes Consul to not rejoin\n\t// the cluster until an explicit join is received. If this is set to\n\t// true, we ignore the leave, and rejoin the cluster on start.\n\tRejoinAfterLeave bool `mapstructure:\"rejoin_after_leave\"`\n\n\t// CheckUpdateInterval controls the interval on which the output of a health check\n\t// is updated if there is no change to the state. For example, a check in a steady\n\t// state may run every 5 second generating a unique output (timestamp, etc), forcing\n\t// constant writes. This allows Consul to defer the write for some period of time,\n\t// reducing the write pressure when the state is steady.\n\tCheckUpdateInterval    time.Duration `mapstructure:\"-\"`\n\tCheckUpdateIntervalRaw string        `mapstructure:\"check_update_interval\" json:\"-\"`\n\n\t// ACLToken is the default token used to make requests if a per-request\n\t// token is not provided. If not configured the 'anonymous' token is used.\n\tACLToken string `mapstructure:\"acl_token\" json:\"-\"`\n\n\t// ACLMasterToken is used to bootstrap the ACL system. It should be specified\n\t// on the servers in the ACLDatacenter. When the leader comes online, it ensures\n\t// that the Master token is available. This provides the initial token.\n\tACLMasterToken string `mapstructure:\"acl_master_token\" json:\"-\"`\n\n\t// ACLDatacenter is the central datacenter that holds authoritative\n\t// ACL records. This must be the same for the entire cluster.\n\t// If this is not set, ACLs are not enabled. Off by default.\n\tACLDatacenter string `mapstructure:\"acl_datacenter\"`\n\n\t// ACLTTL is used to control the time-to-live of cached ACLs . This has\n\t// a major impact on performance. By default, it is set to 30 seconds.\n\tACLTTL    time.Duration `mapstructure:\"-\"`\n\tACLTTLRaw string        `mapstructure:\"acl_ttl\"`\n\n\t// ACLDefaultPolicy is used to control the ACL interaction when\n\t// there is no defined policy. This can be \"allow\" which means\n\t// ACLs are used to black-list, or \"deny\" which means ACLs are\n\t// white-lists.\n\tACLDefaultPolicy string `mapstructure:\"acl_default_policy\"`\n\n\t// ACLDownPolicy is used to control the ACL interaction when we cannot\n\t// reach the ACLDatacenter and the token is not in the cache.\n\t// There are two modes:\n\t//   * deny - Deny all requests\n\t//   * extend-cache - Ignore the cache expiration, and allow cached\n\t//                    ACL's to be used to service requests. This\n\t//\t                  is the default. If the ACL is not in the cache,\n\t//                    this acts like deny.\n\tACLDownPolicy string `mapstructure:\"acl_down_policy\"`\n\n\t// Watches are used to monitor various endpoints and to invoke a\n\t// handler to act appropriately. These are managed entirely in the\n\t// agent layer using the standard APIs.\n\tWatches []map[string]interface{} `mapstructure:\"watches\"`\n\n\t// DisableRemoteExec is used to turn off the remote execution\n\t// feature. This is for security to prevent unknown scripts from running.\n\tDisableRemoteExec bool `mapstructure:\"disable_remote_exec\"`\n\n\t// DisableUpdateCheck is used to turn off the automatic update and\n\t// security bulletin checking.\n\tDisableUpdateCheck bool `mapstructure:\"disable_update_check\"`\n\n\t// DisableAnonymousSignature is used to turn off the anonymous signature\n\t// send with the update check. This is used to deduplicate messages.\n\tDisableAnonymousSignature bool `mapstructure:\"disable_anonymous_signature\"`\n\n\t// HTTPAPIResponseHeaders are used to add HTTP header response fields to the HTTP API responses.\n\tHTTPAPIResponseHeaders map[string]string `mapstructure:\"http_api_response_headers\"`\n\n\t// AtlasInfrastructure is the name of the infrastructure we belong to. e.g. hashicorp/stage\n\tAtlasInfrastructure string `mapstructure:\"atlas_infrastructure\"`\n\n\t// AtlasToken is our authentication token from Atlas\n\tAtlasToken string `mapstructure:\"atlas_token\" json:\"-\"`\n\n\t// AtlasACLToken is applied to inbound requests if no other token\n\t// is provided. This takes higher precedence than the ACLToken.\n\t// Without this, the ACLToken is used. If that is not specified either,\n\t// then the 'anonymous' token is used. This can be set to 'anonymous'\n\t// to reduce the Atlas privileges to below that of the ACLToken.\n\tAtlasACLToken string `mapstructure:\"atlas_acl_token\" json:\"-\"`\n\n\t// AtlasJoin controls if Atlas will attempt to auto-join the node\n\t// to it's cluster. Requires Atlas integration.\n\tAtlasJoin bool `mapstructure:\"atlas_join\"`\n\n\t// AEInterval controls the anti-entropy interval. This is how often\n\t// the agent attempts to reconcile it's local state with the server'\n\t// representation of our state. Defaults to every 60s.\n\tAEInterval time.Duration `mapstructure:\"-\" json:\"-\"`\n\n\t// Checks holds the provided check definitions\n\tChecks []*CheckDefinition `mapstructure:\"-\" json:\"-\"`\n\n\t// Services holds the provided service definitions\n\tServices []*ServiceDefinition `mapstructure:\"-\" json:\"-\"`\n\n\t// ConsulConfig can either be provided or a default one created\n\tConsulConfig *consul.Config `mapstructure:\"-\" json:\"-\"`\n\n\t// Revision is the GitCommit this maps to\n\tRevision string `mapstructure:\"-\"`\n\n\t// Version is the release version number\n\tVersion string `mapstructure:\"-\"`\n\n\t// VersionPrerelease is a label for pre-release builds\n\tVersionPrerelease string `mapstructure:\"-\"`\n\n\t// WatchPlans contains the compiled watches\n\tWatchPlans []*watch.WatchPlan `mapstructure:\"-\" json:\"-\"`\n\n\t// UnixSockets is a map of socket configuration data\n\tUnixSockets UnixSocketConfig `mapstructure:\"unix_sockets\"`\n\n\t// Minimum Session TTL\n\tSessionTTLMin    time.Duration `mapstructure:\"-\"`\n\tSessionTTLMinRaw string        `mapstructure:\"session_ttl_min\"`\n}\n```\nConfig 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.\n\n```go\nfunc DecodeConfig(r io.Reader) (*Config, error)\n```\nDecodeConfig reads the configuration from the given reader in JSON format and decodes it into a proper Config structure.\n\n```go\nfunc DefaultConfig() *Config\n```\nDefaultConfig is used to return a sane default configuration\n\n```go\nfunc MergeConfig(a, b *Config) *Config\n```\nMergeConfig merges two configurations together to make a single new configuration.\n\n```go\nfunc ReadConfigPaths(paths []string) (*Config, error)\n```\nReadConfigPaths 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.\n\n```go\nfunc (c *Config) ClientListener(override string, port int) (net.Addr, error)\n```\nClientListener is used to format a listener for a port on a ClientAddr\n\n```go\nfunc (c *Config) EncryptBytes() ([]byte, error)\n```\nEncryptBytes returns the encryption key configured.\n\n```go\ntype DNSConfig struct {\n\t// NodeTTL provides the TTL value for a node query\n\tNodeTTL    time.Duration `mapstructure:\"-\"`\n\tNodeTTLRaw string        `mapstructure:\"node_ttl\" json:\"-\"`\n\n\t// ServiceTTL provides the TTL value for a service\n\t// query for given service. The \"*\" wildcard can be used\n\t// to set a default for all services.\n\tServiceTTL    map[string]time.Duration `mapstructure:\"-\"`\n\tServiceTTLRaw map[string]string        `mapstructure:\"service_ttl\" json:\"-\"`\n\n\t// AllowStale is used to enable lookups with stale\n\t// data. This gives horizontal read scalability since\n\t// any Consul server can service the query instead of\n\t// only the leader.\n\tAllowStale bool `mapstructure:\"allow_stale\"`\n\n\t// EnableTruncate is used to enable setting the truncate\n\t// flag for UDP DNS queries.  This allows unmodified\n\t// clients to re-query the consul server using TCP\n\t// when the total number of records exceeds the number\n\t// returned by default for UDP.\n\tEnableTruncate bool `mapstructure:\"enable_truncate\"`\n\n\t// MaxStale is used to bound how stale of a result is\n\t// accepted for a DNS lookup. This can be used with\n\t// AllowStale to limit how old of a value is served up.\n\t// If the stale result exceeds this, another non-stale\n\t// stale read is performed.\n\tMaxStale    time.Duration `mapstructure:\"-\"`\n\tMaxStaleRaw string        `mapstructure:\"max_stale\" json:\"-\"`\n\n\t// OnlyPassing is used to determine whether to filter nodes\n\t// whose health checks are in any non-passing state. By\n\t// default, only nodes in a critical state are excluded.\n\tOnlyPassing bool `mapstructure:\"only_passing\"`\n}\n```\nDNSConfig is used to fine tune the DNS sub-system. It can be used to control cache values, and stale reads\n\n```go\ntype DNSServer struct {\n\t// contains filtered or unexported fields\n}\n```\nDNSServer is used to wrap an Agent and expose various service discovery endpoints using a DNS interface.\n\n```go\nfunc NewDNSServer(agent *Agent, config *DNSConfig, logOutput io.Writer, domain string, bind string, recursors []string) (*DNSServer, error)\n```\nNewDNSServer starts a new DNS server to provide an agent interface\n\n```go\nfunc (d *DNSServer) Shutdown()\n```\nShutdown stops the DNS Servers\n\n```go\ntype FilePermissions interface {\n\t// User returns a user ID or user name\n\tUser() string\n\n\t// Group returns a group ID. Group names are not supported.\n\tGroup() string\n\n\t// Mode returns a string of file mode bits e.g. \"0644\"\n\tMode() string\n}\n```\nFilePermissions is an interface which allows a struct to set ownership and permissions easily on a file it describes.\n\n```go\ntype GatedWriter struct {\n\tWriter io.Writer\n\t// contains filtered or unexported fields\n}\n```\nGatedWriter is an io.Writer implementation that buffers all of its data into an internal buffer until it is told to let data through.\n\n```go\nfunc (w *GatedWriter) Flush()\n```\nFlush tells the GatedWriter to flush any buffered data and to stop buffering.\n\n```go\nfunc (w *GatedWriter) Write(p []byte) (n int, err error)\n```\n\n```go\ntype HTTPServer struct {\n\t// contains filtered or unexported fields\n}\n```\nHTTPServer is used to wrap an Agent and expose various API's in a RESTful manner\n\n```go\nfunc NewHTTPServers(agent *Agent, config *Config, scada net.Listener, logOutput io.Writer) ([]*HTTPServer, error)\n```\nNewHTTPServers starts new HTTP servers to provide an interface to the agent.\n\n```go\nfunc (s *HTTPServer) ACLClone(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) ACLCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) ACLDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) ACLGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) ACLList(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) ACLUpdate(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentCheckFail(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentCheckPass(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentCheckWarn(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentDeregisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentDeregisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentForceLeave(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentJoin(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentMembers(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentNodeMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentRegisterCheck(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentServiceMaintenance(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) AgentServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogDatacenters(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogDeregister(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogNodeServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogRegister(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) CatalogServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) EventFire(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nEventFire is used to fire a new event\n\n```go\nfunc (s *HTTPServer) EventList(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nEventList is used to retrieve the recent list of events\n\n```go\nfunc (s *HTTPServer) HealthChecksInState(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) HealthNodeChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) HealthServiceChecks(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) HealthServiceNodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request)\n```\nRenders a simple index page\n\n```go\nfunc (s *HTTPServer) KVSDelete(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)\n```\nKVSPut handles a DELETE request\n\n```go\nfunc (s *HTTPServer) KVSEndpoint(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) KVSGet(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)\n```\nKVSGet handles a GET request\n\n```go\nfunc (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)\n```\nKVSGetKeys handles a GET request for keys\n\n```go\nfunc (s *HTTPServer) KVSPut(resp http.ResponseWriter, req *http.Request, args *structs.KeyRequest) (interface{}, error)\n```\nKVSPut handles a PUT request\n\n```go\nfunc (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionCreate is used to create a new session\n\n```go\nfunc (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionDestroy is used to destroy an existing session\n\n```go\nfunc (s *HTTPServer) SessionGet(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionGet is used to get info for a particular session\n\n```go\nfunc (s *HTTPServer) SessionList(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionList is used to list all the sessions\n\n```go\nfunc (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionRenew is used to renew the TTL on an existing TTL session\n\n```go\nfunc (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nSessionsForNode returns all the nodes belonging to a node\n\n```go\nfunc (s *HTTPServer) Shutdown()\n```\nShutdown is used to shutdown the HTTP server\n\n```go\nfunc (s *HTTPServer) StatusLeader(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) StatusPeers(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\n\n```go\nfunc (s *HTTPServer) UINodeInfo(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nUINodeInfo is used to get info on a single node in a given datacenter. We return a NodeInfo which provides overview information for the node\n\n```go\nfunc (s *HTTPServer) UINodes(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nUINodes is used to list the nodes in a given datacenter. We return a NodeDump which provides overview information for all the nodes\n\n```go\nfunc (s *HTTPServer) UIServices(resp http.ResponseWriter, req *http.Request) (interface{}, error)\n```\nUIServices is used to list the services in a given datacenter. We return a ServiceSummary which provides overview information for the service\n\n```go\ntype KeyringEntry struct {\n\tDatacenter string\n\tPool       string\n\tKey        string\n\tCount      int\n}\n```\n\n```go\ntype KeyringInfo struct {\n\tDatacenter string\n\tPool       string\n\tNumNodes   int\n\tError      string\n}\n```\n\n```go\ntype KeyringMessage struct {\n\tDatacenter string\n\tPool       string\n\tNode       string\n\tMessage    string\n}\n```\n\n```go\ntype LogHandler interface {\n\tHandleLog(string)\n}\n```\nLogHandler interface is used for clients that want to subscribe to logs, for example to stream them over an IPC mechanism\n\n```go\ntype Member struct {\n\tName        string\n\tAddr        net.IP\n\tPort        uint16\n\tTags        map[string]string\n\tStatus      string\n\tProtocolMin uint8\n\tProtocolMax uint8\n\tProtocolCur uint8\n\tDelegateMin uint8\n\tDelegateMax uint8\n\tDelegateCur uint8\n}\n```\n\n```go\ntype PortConfig struct {\n\tDNS     int // DNS Query interface\n\tHTTP    int // HTTP API\n\tHTTPS   int // HTTPS API\n\tRPC     int // CLI RPC\n\tSerfLan int `mapstructure:\"serf_lan\"` // LAN gossip (Client + Server)\n\tSerfWan int `mapstructure:\"serf_wan\"` // WAN gossip (Server onlyg)\n\tServer  int // Server internal RPC\n}\n```\nPorts is used to simplify the configuration by providing default ports, and allowing the addresses to only be specified once\n\n```go\ntype RPCClient struct {\n\t// contains filtered or unexported fields\n}\n```\nRPCClient is the RPC client to make requests to the agent RPC.\n\n```go\nfunc NewRPCClient(addr string) (*RPCClient, error)\n```\nNewRPCClient is used to create a new RPC client given the address. This will properly dial, handshake, and start listening\n\n```go\nfunc (c *RPCClient) Close() error\n```\nClose is used to free any resources associated with the client\n\n```go\nfunc (c *RPCClient) ForceLeave(node string) error\n```\nForceLeave is used to ask the agent to issue a leave command for a given node\n\n```go\nfunc (c *RPCClient) InstallKey(key string) (keyringResponse, error)\n```\n\n```go\nfunc (c *RPCClient) Join(addrs []string, wan bool) (int, error)\n```\nJoin is used to instruct the agent to attempt a join\n\n```go\nfunc (c *RPCClient) LANMembers() ([]Member, error)\n```\nLANMembers is used to fetch a list of known members\n\n```go\nfunc (c *RPCClient) Leave() error\n```\nLeave is used to trigger a graceful leave and shutdown\n\n```go\nfunc (c *RPCClient) ListKeys() (keyringResponse, error)\n```\n\n```go\nfunc (c *RPCClient) Monitor(level logutils.LogLevel, ch chan\u003c- string) (StreamHandle, error)\n```\nMonitor is used to subscribe to the logs of the agent\n\n```go\nfunc (c *RPCClient) Reload() error\n```\nReload is used to trigger a configuration reload\n\n```go\nfunc (c *RPCClient) RemoveKey(key string) (keyringResponse, error)\n```\n\n```go\nfunc (c *RPCClient) Stats() (map[string]map[string]string, error)\n```\nStats is used to get debugging state information\n\n```go\nfunc (c *RPCClient) Stop(handle StreamHandle) error\n```\nStop is used to unsubscribe from logs or event streams\n\n```go\nfunc (c *RPCClient) UseKey(key string) (keyringResponse, error)\n```\n\n```go\nfunc (c *RPCClient) WANMembers() ([]Member, error)\n```\nWANMembers is used to fetch a list of known members\n\n```go\ntype ServiceDefinition struct {\n\tID      string\n\tName    string\n\tTags    []string\n\tAddress string\n\tPort    int\n\tCheck   CheckType\n\tChecks  CheckTypes\n\tToken   string\n}\n```\nServiceDefinition is used to JSON decode the Service definitions\n\n```go\nfunc DecodeServiceDefinition(raw interface{}) (*ServiceDefinition, error)\n```\nDecodeServiceDefinition is used to decode a service definition\n\n```go\nfunc (s *ServiceDefinition) CheckTypes() (checks CheckTypes)\n```\n\n```go\nfunc (s *ServiceDefinition) NodeService() *structs.NodeService\n```\n\n```go\ntype ServiceSummary struct {\n\tName           string\n\tNodes          []string\n\tChecksPassing  int\n\tChecksWarning  int\n\tChecksCritical int\n}\n```\nServiceSummary is used to summarize a service\n\n```go\ntype StreamHandle uint64\n```\nStreamHandle is an opaque handle passed to stop to stop streaming\n\n```go\ntype SyslogWrapper struct {\n\t// contains filtered or unexported fields\n}\n```\nSyslogWrapper is used to cleaup log messages before writing them to a Syslogger. Implements the io.Writer interface.\n\n```go\nfunc (s *SyslogWrapper) Write(p []byte) (int, error)\n```\nWrite is used to implement io.Writer\n\n```go\ntype UnixSocketConfig struct {\n\tUnixSocketPermissions `mapstructure:\",squash\"`\n}\n```\nUnixSocketConfig stores information about various unix sockets which Consul creates and uses for communication.\n\n```go\ntype UnixSocketPermissions struct {\n\tUsr   string `mapstructure:\"user\"`\n\tGrp   string `mapstructure:\"group\"`\n\tPerms string `mapstructure:\"mode\"`\n}\n```\nUnixSocketPermissions contains information about a unix socket, and implements the FilePermissions interface.\n\n```go\nfunc (u UnixSocketPermissions) Group() string\n```\n\n```go\nfunc (u UnixSocketPermissions) Mode() string\n```\n\n```go\nfunc (u UnixSocketPermissions) User() string\n```\n\n```go\ntype UserEvent struct {\n\t// ID of the user event. Automatically generated.\n\tID string\n\n\t// Name of the event\n\tName string `codec:\"n\"`\n\n\t// Optional payload\n\tPayload []byte `codec:\"p,omitempty\"`\n\n\t// NodeFilter is a regular expression to filter on nodes\n\tNodeFilter string `codec:\"nf,omitempty\"`\n\n\t// ServiceFilter is a regular expression to filter on services\n\tServiceFilter string `codec:\"sf,omitempty\"`\n\n\t// TagFilter is a regular expression to filter on tags of a service,\n\t// must be provided with ServiceFilter\n\tTagFilter string `codec:\"tf,omitempty\"`\n\n\t// Version of the user event. Automatically generated.\n\tVersion int `codec:\"v\"`\n\n\t// LTime is the lamport time. Automatically generated.\n\tLTime uint64 `codec:\"-\"`\n}\n```\nUserEventParam is used to parameterize a user event\n\n","path":"github.com/stackdocker/consul/command/agent","name":"agent","synopsis":"","isRedistributable":true}
