Documentation ¶
Overview ¶
Package etcd manages the embedded etcd server that Sensu uses for storing state consistently across sensu-backend processes.
To use the embedded Etcd, you must first call NewEtcd(). This will configure and start Etcd and ensure that it starts correctly. The channel returned by Err() should be monitored--these are terminal/fatal errors for Etcd.
Index ¶
- Constants
- func NewLogrusFormatter() capnslog.Formatter
- func Sequence(ctx context.Context, kv clientv3.KV, key string) (result string, err error)
- func Sequences(ctx context.Context, kv clientv3.KV, key string, values int) ([]string, error)
- type BackendIDGetter
- type BackendIDGetterClient
- type Config
- type Etcd
- type TLSInfo
Constants ¶
const ( // ClusterStateNew specifies this is a new etcd cluster ClusterStateNew = "new" // EtcdStartupTimeout is the amount of time we give the embedded Etcd Server // to start. EtcdStartupTimeout = 60 // seconds // DefaultMaxRequestBytes is the default maximum request size for etcd // requests (1.5 MB) DefaultMaxRequestBytes = 1.5 * (1 << 20) // DefaultQuotaBackendBytes is the default database size limit for etcd // databases (4 GB) DefaultQuotaBackendBytes int64 = (1 << 32) )
Variables ¶
This section is empty.
Functions ¶
func NewLogrusFormatter ¶
NewLogrusFormatter creates a new LogrusFormatter
func Sequence ¶
Sequence provides an incrementing sequence ID. The ID is a big-endian encoded uint64 value that starts at 0.
If the key provided does not contain a sequence yet, one is created and incremented to 1. If the sequence already exists, then the next ID in the sequence will be returned.
Because sequence IDs are big-endian encoded strings, they can be ordered with lexicographic sorting. This makes them a useful key for ordered collections.
Sequence is not transactional, but is safe to use concurrently. If two clients are both using Sequence on the same key, they will race to be the one who updates the sequence. The loser of the race will execute the routine again.
Types ¶
type BackendIDGetter ¶
type BackendIDGetter struct {
// contains filtered or unexported fields
}
BackendIDGetter is a type that facilitates identifying a sensu backend.
func NewBackendIDGetter ¶
func NewBackendIDGetter(ctx context.Context, client BackendIDGetterClient) *BackendIDGetter
NewBackendIDGetter creates a new BackendIDGetter. It uses a context that should be valid for the life of the application, to pass to etcd. It requires a BackendIDGetterClient, which users can provide by using an etcd *clientv3.Client.
func (*BackendIDGetter) GetBackendID ¶
func (b *BackendIDGetter) GetBackendID() int64
type BackendIDGetterClient ¶
type BackendIDGetterClient interface { Grant(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error) KeepAlive(ctx context.Context, id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) }
BackendIDGetterClient represents the dependencies for BackendIDGetter.
type Config ¶
type Config struct { DataDir string Name string // Cluster Member Name AdvertiseClientURLs []string ListenPeerURLs []string ListenClientURLs []string InitialCluster string InitialClusterState string InitialClusterToken string InitialAdvertisePeerURLs []string ClientTLSInfo TLSInfo PeerTLSInfo TLSInfo CipherSuites []string MaxRequestBytes uint QuotaBackendBytes int64 }
Config is a configuration for the embedded etcd
type Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
Etcd is a wrapper around github.com/coreos/etcd/embed.Etcd
func NewEtcd ¶
NewEtcd returns a new, configured, and running Etcd. The running Etcd will panic on error. The calling goroutine should recover() from the panic and shutdown accordingly. Callers must also ensure that the running Etcd is cleanly shutdown before the process terminates.
Callers should monitor the Err() channel for the running etcd--these are terminal errors.
func NewTestEtcd ¶
NewTestEtcd creates a new Etcd for testing purposes.
func (*Etcd) ClientURLs ¶
func (*Etcd) GetClusterVersion ¶
GetClusterVersion returns the cluster version of the etcd server