store

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEtcdEndpoints   = "http://127.0.0.1:2379"
	DefaultConsulEndpoints = "http://127.0.0.1:8500"
)
View Source
const (
	//TODO(sgotti) fix this in libkv?
	// consul min ttl is 10s and libkv divides this by 2
	MinTTL = 20 * time.Second
)

Variables

View Source
var (
	// ErrKeyNotFound is thrown when the key is not found in the store during a Get operation
	ErrKeyNotFound      = errors.New("Key not found in store")
	ErrKeyModified      = errors.New("Unable to complete atomic operation, key modified")
	ErrElectionNoLeader = errors.New("election: no leader")
)
View Source
var URLSchemeRegexp = regexp.MustCompile(`^([a-zA-Z][a-zA-Z0-9+-.]*)://`)

Functions

This section is empty.

Types

type Backend

type Backend string

Backend represents a KV Store Backend

const (
	CONSUL Backend = "consul"
	ETCDV2 Backend = "etcdv2"
	ETCDV3 Backend = "etcdv3"
)

type Config added in v0.5.0

type Config struct {
	Backend       Backend
	Endpoints     string
	CertFile      string
	KeyFile       string
	CAFile        string
	SkipTLSVerify bool
}

type Election added in v0.8.0

type Election interface {
	// TODO(sgotti) this mimics the current docker/leadership API and the etcdv3
	// implementations adapt to it. In future it could be replaced with a better
	// api like the current one implemented by etcdclientv3/concurrency.
	RunForElection() (<-chan bool, <-chan error)
	Leader() (string, error)
	Stop()
}

func NewElection added in v0.8.0

func NewElection(kvStore KVStore, path, candidateUID string) Election

type KVPair added in v0.8.0

type KVPair struct {
	Key       string
	Value     []byte
	LastIndex uint64
}

KVPair represents {Key, Value, Lastindex} tuple

type KVStore added in v0.8.0

type KVStore interface {
	// Put a value at the specified key
	Put(ctx context.Context, key string, value []byte, options *WriteOptions) error

	// Get a value given its key
	Get(ctx context.Context, key string) (*KVPair, error)

	// List the content of a given prefix
	List(ctx context.Context, directory string) ([]*KVPair, error)

	// Atomic CAS operation on a single value.
	// Pass previous = nil to create a new key.
	AtomicPut(ctx context.Context, key string, value []byte, previous *KVPair, options *WriteOptions) (*KVPair, error)

	Delete(ctx context.Context, key string) error

	// Close the store connection
	Close() error
}

func NewKVStore added in v0.8.0

func NewKVStore(cfg Config) (KVStore, error)

type Store added in v0.8.0

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(kvStore KVStore, path string) *Store

func (*Store) AtomicPutClusterData added in v0.8.0

func (s *Store) AtomicPutClusterData(ctx context.Context, cd *cluster.ClusterData, previous *KVPair) (*KVPair, error)

func (*Store) GetClusterData added in v0.8.0

func (s *Store) GetClusterData(ctx context.Context) (*cluster.ClusterData, *KVPair, error)

func (*Store) GetKeeperInfo added in v0.8.0

func (s *Store) GetKeeperInfo(ctx context.Context, id string) (*cluster.KeeperInfo, bool, error)

func (*Store) GetKeepersInfo added in v0.8.0

func (s *Store) GetKeepersInfo(ctx context.Context) (cluster.KeepersInfo, error)

func (*Store) GetLeaderSentinelId added in v0.8.0

func (s *Store) GetLeaderSentinelId(ctx context.Context) (string, error)

func (*Store) GetProxiesInfo added in v0.8.0

func (s *Store) GetProxiesInfo(ctx context.Context) (cluster.ProxiesInfo, error)

func (*Store) GetProxyInfo added in v0.8.0

func (s *Store) GetProxyInfo(ctx context.Context, id string) (*cluster.ProxyInfo, bool, error)

func (*Store) GetSentinelInfo added in v0.8.0

func (s *Store) GetSentinelInfo(ctx context.Context, id string) (*cluster.SentinelInfo, bool, error)

func (*Store) GetSentinelsInfo added in v0.8.0

func (s *Store) GetSentinelsInfo(ctx context.Context) (cluster.SentinelsInfo, error)

func (*Store) PutClusterData added in v0.8.0

func (s *Store) PutClusterData(ctx context.Context, cd *cluster.ClusterData) error

func (*Store) SetKeeperInfo added in v0.8.0

func (s *Store) SetKeeperInfo(ctx context.Context, id string, ms *cluster.KeeperInfo, ttl time.Duration) error

func (*Store) SetProxyInfo added in v0.8.0

func (s *Store) SetProxyInfo(ctx context.Context, pi *cluster.ProxyInfo, ttl time.Duration) error

func (*Store) SetSentinelInfo added in v0.8.0

func (s *Store) SetSentinelInfo(ctx context.Context, si *cluster.SentinelInfo, ttl time.Duration) error

type WriteOptions added in v0.8.0

type WriteOptions struct {
	TTL time.Duration
}

Jump to

Keyboard shortcuts

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