internal

package
v0.0.0-...-781a829 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Delimiter is a separator that separates the etcd path.
	Delimiter = '/'
)

Variables

View Source
var (
	// DialTimeout is the dial timeout.
	DialTimeout = dialTimeout
	// RequestTimeout is the request timeout.
	RequestTimeout = requestTimeout
	// NewClient is used to create etcd clients.
	NewClient = DialClient
)

Functions

This section is empty.

Types

type DoneChan

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

A DoneChan is used as a channel that can be closed multiple times and wait for done.

func NewDoneChan

func NewDoneChan() *DoneChan

NewDoneChan returns a DoneChan.

func (*DoneChan) Close

func (dc *DoneChan) Close()

Close closes dc, it's safe to close more than once.

func (*DoneChan) Done

func (dc *DoneChan) Done() chan PlaceholderType

Done returns a channel that can be notified on dc closed.

type EtcdClient

type EtcdClient interface {
	ActiveConnection() *grpc.ClientConn
	Close() error
	Ctx() context.Context
	Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
	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)
	Revoke(ctx context.Context, id clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)
	Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
}

EtcdClient interface represents an etcd client.

func DialClient

func DialClient(endpoints []string) (EtcdClient, error)

DialClient dials an etcd cluster with given endpoints.

type GenericType

type GenericType = interface{}

GenericType can be used to hold any type.

type KV

type KV struct {
	Key string
	Val string
}

A KV is used to store an etcd entry with key and value.

type Listener

type Listener interface {
	OnUpdate(keys []string, values []string, newKey string)
}

Listener interface wraps the OnUpdate method.

type PlaceholderType

type PlaceholderType = struct{}

PlaceholderType represents a placeholder type.

var Placeholder PlaceholderType

Placeholder is a placeholder object that can be used globally.

type Registry

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

A Registry is a registry that manages the etcd client connections.

func GetRegistry

func GetRegistry() *Registry

GetRegistry returns a global Registry.

func (*Registry) GetConn

func (r *Registry) GetConn(endpoints []string) (EtcdClient, error)

GetConn returns an etcd client connection associated with given endpoints.

func (*Registry) Monitor

func (r *Registry) Monitor(endpoints []string, key string, l UpdateListener) error

Monitor monitors the key on given etcd endpoints, notify with the given UpdateListener.

type UpdateListener

type UpdateListener interface {
	OnAdd(kv KV)
	OnDelete(kv KV)
}

UpdateListener wraps the OnAdd and OnDelete methods.

Jump to

Keyboard shortcuts

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