etcd

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2017 License: Apache-2.0 Imports: 15 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyAlreadyExists - Testable error for when a key already exists
	ErrKeyAlreadyExists = errors.New("Key Already Exists")

	// ErrKeyMissing - testable error for no expected key defined
	ErrKeyMissing = errors.New("Key not defined")
)
View Source
var ExtKeyUsage = map[string]x509.ExtKeyUsage{
	"any":              x509.ExtKeyUsageAny,
	"server auth":      x509.ExtKeyUsageServerAuth,
	"client auth":      x509.ExtKeyUsageClientAuth,
	"code signing":     x509.ExtKeyUsageCodeSigning,
	"email protection": x509.ExtKeyUsageEmailProtection,
	"s/mime":           x509.ExtKeyUsageEmailProtection,
	"ipsec end system": x509.ExtKeyUsageIPSECEndSystem,
	"ipsec tunnel":     x509.ExtKeyUsageIPSECTunnel,
	"ipsec user":       x509.ExtKeyUsageIPSECUser,
	"timestamping":     x509.ExtKeyUsageTimeStamping,
	"ocsp signing":     x509.ExtKeyUsageOCSPSigning,
	"microsoft sgc":    x509.ExtKeyUsageMicrosoftServerGatedCrypto,
	"netscape sgc":     x509.ExtKeyUsageNetscapeServerGatedCrypto,
}

ExtKeyUsage - contains a mapping of string names to extended key usages.

View Source
var (
	// Timeout - For now a constant
	Timeout = 5 * time.Second
)

Functions

func GenCerts

func GenCerts(cfg ServerConfig) (err error)

GenCerts - Will generate etcd server and client certs from appropriate CA and key

Types

type Client added in v0.0.4

type Client struct {
	Endpoints          string
	CaFileName         string
	ClientCertFileName string
	ClientKeyFileName  string
	LockTTL            time.Duration
}

Client represents an etcd client configuration.

func New added in v0.0.4

func New(cfg Client) *Client

New creates a new etcd client from configuration

func (*Client) Delete added in v0.0.4

func (c *Client) Delete(key string) (err error)

Delete - will remove a key from etcd

func (*Client) Get added in v0.0.4

func (c *Client) Get(key string) (value string, err error)

Get - Will return: - The the string value for a given key if present - Will return an err for all other occasions

func (*Client) GetOrCreateLock added in v0.0.4

func (c *Client) GetOrCreateLock(key string, lockKeyTTL time.Duration) (mylock bool, err error)

GetOrCreateLock obtains a lock (true) if the first client to create lock If TTL expired, will obtain lock (reset TTL) If TTL not expired will return false

func (*Client) OverWriteLock added in v0.0.4

func (c *Client) OverWriteLock(key string) (err error)

OverWriteLock will delete and re-create a lock TODO: this needs to be done as a transaction!

func (*Client) PutTx added in v0.0.4

func (c *Client) PutTx(key string, value string) (err error)

PutTx - Puts with a transaction (will NOT create new revision) Will ensure only a single version is ever stored. Returns error if key already existed

func (*Client) SetLock added in v0.0.4

func (c *Client) SetLock(key string) (err error)

SetLock create an ETCD lock key with a TTL from now

func (*Client) TryRecreateLock added in v0.0.4

func (c *Client) TryRecreateLock(key string) (recreated bool, err error)

TryRecreateLock will recreate a Lock IF TTL of existing lock has expired. Returns true if lock obtained (re-created as TTL expired) Returns false if existing lock still valid

type Clienter added in v0.0.4

type Clienter interface {
	Get(key string) (value string, err error)
	GetOrCreateLock(key string, lockKeyTTL time.Duration) (mylock bool, err error)
	PutTx(key string, value string) (err error)
	Delete(key string) (err error)
}

Clienter allows for mocking out this lib for testing

type ServerConfig

type ServerConfig struct {
	CaKeyFileName      string
	ServerCertFileName string
	ServerKeyFileName  string
	PeerCertFileName   string
	PeerKeyFileName    string
	LocalHostNames     []string
	ClusterHostNames   []string
	ClientConfig       Client
}

ServerConfig - Params for configuring an etcd cluster

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL