package
1.0.14
Repository: https://github.com/zhyocean/neuvector.git
Documentation: pkg.go.dev

# README

Consul API client

This package provides the api package which attempts to provide programmatic access to the full Consul API.

Currently, all of the Consul APIs included in version 0.6.0 are supported.

Documentation

The full documentation is available on Godoc

Usage

Below is an example of using the Consul client:

package main

import "github.com/hashicorp/consul/api"
import "fmt"

func main() {
	// Get a new client
	client, err := api.NewClient(api.DefaultConfig())
	if err != nil {
		panic(err)
	}

	// Get a handle to the KV API
	kv := client.KV()

	// PUT a new KV pair
	p := &api.KVPair{Key: "REDIS_MAXCLIENTS", Value: []byte("1000")}
	_, err = kv.Put(p, nil)
	if err != nil {
		panic(err)
	}

	// Lookup the pair
	pair, _, err := kv.Get("REDIS_MAXCLIENTS", nil)
	if err != nil {
		panic(err)
	}
	fmt.Printf("KV: %v %s\n", pair.Key, pair.Value)
}

To run this example, start a Consul server:

consul agent -dev

Copy the code above into a file such as main.go.

Install and run. You'll see a key (REDIS_MAXCLIENTS) and value (1000) printed.

$ go get
$ go run main.go
KV: REDIS_MAXCLIENTS 1000

After running the code, you can also view the values in the Consul UI on your local machine at http://localhost:8500/ui/dc1/kv

# Functions

No description provided by the author
No description provided by the author
DefaultConfig returns a default configuration for the client.
DefaultNonPooledConfig returns a default configuration for the client which does not pool connections.
IsRetryableError returns true for 500 errors from the Consul servers, and network connection errors.
NewClient returns a new client.
NewHttpClient returns an http client configured with the given Transport and TLS config.
No description provided by the author
ParseConsulCAConfig takes a raw config map and returns a parsed ConsulCAProviderConfig.
ParseKubernetesAuthMethodConfig takes a raw config map and returns a parsed KubernetesAuthMethodConfig.
TLSConfig is used to generate a TLSClientConfig that's useful for talking to Consul using TLS.

# Constants

ACLClientType is the client type token.
ACLManagementType is the management type token.
AllSegments is used to select for all segments in MembersOpts.
BindingRuleBindTypeRole binds to pre-existing roles with the given name.
BindingRuleBindTypeService binds to a service identity with the given name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DefaultLockRetryTime is how long we wait after a failed lock acquisition before attempting to do the lock again.
DefaultLockSessionName is the Session Name we assign if none is provided.
DefaultLockSessionTTL is the default session TTL if no Session is provided when creating a new Lock.
DefaultLockWaitTime is how long we block for at a time to check if lock acquisition is possible.
DefaultMonitorRetryTime is how long we wait after a failed monitor check of a lock (500 response code).
DefaultSemaphoreKey is the key used within the prefix to use for coordination between all the contenders.
DefaultSemaphoreSessionName is the Session Name we assign if none is provided.
DefaultSemaphoreSessionTTL is the default session TTL if no Session is provided when creating a new Semaphore.
DefaultSemaphoreWaitTime is how long we block for at a time to check if semaphore acquisition is possible.
GRPCAddrEnvName defines an environment variable name which sets the gRPC address for consul connect envoy.
HealthAny is special, and is used as a wild card, not as a specific state.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HTTPAddrEnvName defines an environment variable name which sets the HTTP address if there is no -http-addr specified.
HTTPAuthEnvName defines an environment variable name which sets the HTTP authentication header.
HTTPCAFile defines an environment variable name which sets the CA file to use for talking to Consul over TLS.
HTTPCAPath defines an environment variable name which sets the path to a directory of CA certs to use for talking to Consul over TLS.
HTTPClientCert defines an environment variable name which sets the client cert file to use for talking to Consul over TLS.
HTTPClientKey defines an environment variable name which sets the client key file to use for talking to Consul over TLS.
HTTPSSLEnvName defines an environment variable name which sets whether or not to use HTTPS.
HTTPSSLVerifyEnvName defines an environment variable name which sets whether or not to disable certificate checking.
HTTPTLSServerName defines an environment variable name which sets the server name to use as the SNI host when connecting via TLS.
HTTPTokenEnvName defines an environment variable name which sets the HTTP token.
HTTPTokenFileEnvName defines an environment variable name which sets the HTTP token file.
No description provided by the author
No description provided by the author
IntentionDefaultNamespace is the default namespace value.
No description provided by the author
No description provided by the author
IntentionSourceConsul is a service within the Consul catalog.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LockFlagValue is a magic flag we set to indicate a key is being used for a lock.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NodeMaint is the special key set by a node in maintenance mode.
No description provided by the author
No description provided by the author
No description provided by the author
ProxyExecModeDaemon indicates that the proxy command should be long-running and should be started and supervised by the agent until it's target service is deregistered.
ProxyExecModeScript indicates that the proxy command should be invoke to completion on each change to the configuration of lifecycle event.
SemaphoreFlagValue is a magic flag we set to indicate a key is being used for a semaphore.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ServiceKindConnectProxy is a proxy for the Connect feature.
ServiceKindTypical is a typical, classic Consul service.
ServiceMaintPrefix is the prefix for a service in maintenance mode.
No description provided by the author
SessionBehaviorDelete is new in Consul 0.5 and changes the behavior to delete all associated locks on session invalidation.
SessionBehaviorRelease is the default behavior and causes all associated locks to be released on session invalidation.
UpstreamDestTypePreparedQuery discovers instances via prepared query execution.
UpstreamDestTypeService discovers instances via healthy service lookup.

# Variables

ErrLockConflict is returned if the flags on a key used for a lock do not match expectation.
ErrLockHeld is returned if we attempt to double lock.
ErrLockInUse is returned if we attempt to destroy a lock that is in use.
ErrLockNotHeld is returned if we attempt to unlock a lock that we do not hold.
ErrSemaphoreConflict is returned if the flags on a key used for a semaphore do not match expectation.
ErrSemaphoreHeld is returned if we attempt to double lock.
ErrSemaphoreInUse is returned if we attempt to destroy a semaphore that is in use.
ErrSemaphoreNotHeld is returned if we attempt to unlock a semaphore that we do not hold.
No description provided by the author

# Structs

ACL can be used to query the ACL endpoints.
No description provided by the author
No description provided by the author
No description provided by the author
ACLEntry is used to represent a legacy ACL token The legacy tokens are deprecated.
No description provided by the author
ACLPolicy represents an ACL Policy.
No description provided by the author
ACLReplicationStatus is used to represent the status of ACL replication.
ACLRole represents an ACL Role.
No description provided by the author
ACLServiceIdentity represents a high-level grant of all necessary privileges to assume the identity of the named Service in the Catalog and within Connect.
ACLToken represents an ACL Token.
No description provided by the author
No description provided by the author
No description provided by the author
Agent can be used to query the Agent endpoints.
AgentAuthorize is the response structure for Connect authorization.
AgentAuthorizeParams are the request parameters for authorizing a request.
AgentCheck represents a check known to the agent.
AgentCheckRegistration is used to register a new check.
AgentMember represents a cluster member known to the agent.
AgentService represents a service known to the agent.
AgentServiceCheck is used to define a node or service level check.
AgentServiceChecksInfo returns information about a Service and its checks.
AgentServiceConnect represents the Connect configuration of a service.
AgentServiceConnectProxy represents the Connect Proxy configuration of a service.
AgentServiceConnectProxyConfig is the proxy configuration in a connect-proxy ServiceDefinition or response.
AgentServiceRegistration is used to register a new service.
AgentToken is used when updating ACL tokens for an agent.
AgentWeights represent optional weights for a service.
Area defines a network area.
AreaJoinResponse is returned when a join occurs and gives the result for each address.
AutopilotConfiguration is used for querying/setting the Autopilot configuration.
CAConfig is the structure for the Connect CA configuration.
CARoot represents a root CA certificate that is trusted.
CARootList is the structure for the results of listing roots.
Catalog can be used to query the Catalog endpoints.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CheckTxnOp defines a single operation inside a transaction.
Client provides a client to the Consul API.
CommonCAProviderConfig is the common options available to all CA providers.
Config is used to configure the creation of a client.
Config can be used to query the Config endpoints.
Connect can be used to work with endpoints related to Connect, the feature for securely connecting services within Consul.
ConnectProxyConfig is the response structure for agent-local proxy configuration.
ConsulCAProviderConfig is the config for the built-in Consul CA provider.
Coordinate can be used to query the coordinate endpoints.
CoordinateDatacenterMap has the coordinates for servers in a given datacenter and area.
CoordinateEntry represents a node and its associated network coordinate.
Debug can be used to query the /debug/pprof endpoints to gather profiling information about the target agent.Debug The agent must have enable_debug set to true for profiling to be enabled and for these endpoints to function.
Event can be used to query the Event endpoints.
GaugeValue stores one value that is updated as time goes on, such as the amount of memory allocated.
Health can be used to query the Health endpoints.
HealthCheck is used to represent a single check.
HealthCheckDefinition is used to store the details about a health check's execution.
HttpBasicAuth is used to authenticate http client with HTTP Basic Authentication.
Intention defines an intention for the Connect Service Graph.
IntentionCheck are the arguments for the intention check API.
IntentionMatch are the arguments for the intention match API.
KeyringResponse is returned when listing the gossip encryption keys.
KubernetesAuthMethodConfig is the config for the built-in Consul auth method for Kubernetes.
KV is used to manipulate the K/V API.
KVPair is used to represent a single K/V entry.
KVTxnOp defines a single operation inside a transaction.
KVTxnResponse has the outcome of a transaction.
LeafCert is a certificate that has been issued by a Connect CA.
Lock is used to implement client-side leader election.
LockOptions is used to parameterize the Lock behavior.
MembersOpts is used for querying member information.
Metrics info is used to store different types of metric values from the agent.
No description provided by the author
NodeTxnOp defines a single operation inside a transaction.
Operator can be used to perform low-level operator tasks for Consul.
OperatorHealthReply is a representation of the overall health of the cluster.
PointValue holds a series of points for a metric.
PreparedQuery can be used to query the prepared query endpoints.
PreparedQueryDefinition defines a complete prepared query.
PreparedQueryExecuteResponse has the results of executing a query.
No description provided by the author
QueryDatacenterOptions sets options about how we fail over if there are no healthy nodes in the local datacenter.
QueryDNSOptions controls settings when query results are served over DNS.
QueryMeta is used to return meta data about a query.
QueryOptions are used to parameterize a query.
QueryTemplate carries the arguments for creating a templated query.
RaftConfiguration is returned when querying for the current Raft configuration.
RaftServer has information about a server in the Raft configuration.
Raw can be used to do raw queries against custom endpoints.
SampledValue stores info about a metric that is incremented over time, such as the number of requests to an HTTP endpoint.
Semaphore is used to implement a distributed semaphore using the Consul KV primitives.
SemaphoreOptions is used to parameterize the Semaphore.
SerfMember is a generic structure for reporting information about members in a Serf cluster.
ServerHealth is the health (from the leader's point of view) of a server.
No description provided by the author
ServiceEntry is used for the health service endpoint.
ServiceQuery is used to query for a set of healthy nodes offering a specific service.
ServiceTxnOp defines a single operation inside a transaction.
Session can be used to query the Session endpoints.
SessionEntry represents a session in consul.
Snapshot can be used to query the /v1/snapshot endpoint to take snapshots of Consul's internal state and restore snapshots for disaster recovery.
Status can be used to query the Status endpoints.
TLSConfig is used to generate a TLSClientConfig that's useful for talking to Consul using TLS.
Txn is used to manipulate the Txn API.
TxnError is used to return information about an operation in a transaction.
TxnOp is the internal format we send to Consul.
TxnResponse is the internal format we receive from Consul.
TxnResult is the internal format we receive from Consul.
Upstream is the response structure for a proxy upstream configuration.
UserEvent represents an event that was fired by the user.
No description provided by the author
WriteMeta is used to return meta data about a write.
WriteOptions are used to parameterize a write.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
BindingRuleBindType is the type of binding rule mechanism used.
CheckOp constants give possible operations available in a transaction.
HealthChecks is a collection of HealthCheck structs.
IntentionAction is the action that the intention represents.
IntentionMatchType is the target for a match request.
IntentionSourceType is the type of the source within an intention.
KVOp constants give possible operations available in a transaction.
KVPairs is a list of KVPair objects.
KVTxnOps defines a set of operations to be performed inside a single transaction.
NodeOp constants give possible operations available in a transaction.
ProxyExecMode is the execution mode for a managed Connect proxy.
ReadableDuration is a duration type that is serialized to JSON in human readable format.
ServiceKind is the kind of service being registered.
ServiceOp constants give possible operations available in a transaction.
TxnErrors is a list of TxnError objects.
TxnOps is a list of transaction operations.
TxnResults is a list of TxnResult objects.
UpstreamDestType is the type of upstream discovery mechanism.