Documentation ¶
Overview ¶
Package consulkv contains implementation of remotekv.Interface for Consul key-value storage.
Index ¶
Constants ¶
const ( // MaxTTL is the maximum TTL that can be set for a session. MaxTTL = 1 * timeutil.Day // MinTTL is the minimum TTL that can be set for a session. MinTTL = 10 * time.Second )
Consul-related constants.
See https://developer.hashicorp.com/consul/api-docs/session#ttl.
const ErrRateLimited errors.Error = "rate limited"
ErrRateLimited is returned by KV.Get when the request is rate limited.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // URL to the Consul key-value storage. URL *url.URL // SessionURL is the URL to the Consul session API. SessionURL *url.URL // Client is the HTTP client for requests to the Consul key-value storage. Client *agdhttp.Client // Limiter rate limits requests to the Consul key-value storage. Limiter *rate.Limiter // TTL defines for how long information about a single client is kept. It // must be between [MinTTL] and [MaxTTL]. TTL time.Duration // MaxRespSize is the maximum size of response from Consul key-value // storage. MaxRespSize datasize.ByteSize }
Config is the configuration structure for Consul key-value storage. All fields must be non-empty.
type KV ¶
type KV struct {
// contains filtered or unexported fields
}
KV is the Consul remote KV implementation.
func (*KV) Get ¶
Get implements the remotekv.Interface interface for *KV. Any error returned will have the underlying type of [httpError].
type KeyReadResponse ¶
type KeyReadResponse struct {
Value []byte `json:"Value"`
}
KeyReadResponse is the item of the array that Consul returns as a response to a GET request to its KV database.
See https://developer.hashicorp.com/consul/api-docs/kv#read-key.