Documentation ¶
Index ¶
- Variables
- func ContainerPath(service, id string) string
- func LeaseBridgePath(service string) string
- func LeaseGuardPath(service string) string
- func LeasePath(service string) string
- func LeaseSessionDir(service string) string
- func LeaseSessionPath(service string, container string) string
- func ServicePath(service string) string
- func SetPfx(v string)
- func ShardDir(service, containerId string) string
- func ShardPath(service, containerId, shardId string) string
- func WatchLoop(ctx context.Context, client EtcdWrapper, key string, rev int64, ...)
- type EtcdClient
- func (w *EtcdClient) CompareAndSwap(ctx context.Context, node string, curValue string, newValue string, ...) (string, error)
- func (w *EtcdClient) CreateAndGet(ctx context.Context, nodes []string, values []string, leaseID clientv3.LeaseID) error
- func (w *EtcdClient) DelKV(ctx context.Context, prefix string) error
- func (w *EtcdClient) DelKVs(ctx context.Context, prefixes []string) error
- func (w *EtcdClient) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
- func (w *EtcdClient) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func (w *EtcdClient) GetClient() *EtcdClient
- func (w *EtcdClient) GetKV(ctx context.Context, node string, opts []clientv3.OpOption) (*clientv3.GetResponse, error)
- func (w *EtcdClient) GetKVs(ctx context.Context, prefix string) (map[string]string, error)
- func (w *EtcdClient) Inc(ctx context.Context, pfx string) (string, error)
- func (w *EtcdClient) NewSession(_ context.Context, client *clientv3.Client, opts ...concurrency.SessionOption) (*concurrency.Session, error)
- func (w *EtcdClient) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
- func (w *EtcdClient) UpdateKV(ctx context.Context, key string, value string) error
- func (w *EtcdClient) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
- type EtcdWrapper
- type MockedEtcdWrapper
- func (m *MockedEtcdWrapper) Close() error
- func (m *MockedEtcdWrapper) CompareAndSwap(ctx context.Context, node string, curValue string, newValue string, ...) (string, error)
- func (m *MockedEtcdWrapper) CreateAndGet(ctx context.Context, nodes []string, values []string, leaseID clientv3.LeaseID) error
- func (m *MockedEtcdWrapper) Ctx() context.Context
- func (m *MockedEtcdWrapper) DelKV(ctx context.Context, prefix string) error
- func (m *MockedEtcdWrapper) DelKVs(ctx context.Context, prefixes []string) error
- func (m *MockedEtcdWrapper) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
- func (m *MockedEtcdWrapper) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func (m *MockedEtcdWrapper) GetClient() *EtcdClient
- func (m *MockedEtcdWrapper) GetKV(ctx context.Context, node string, opts []clientv3.OpOption) (*clientv3.GetResponse, error)
- func (m *MockedEtcdWrapper) GetKVs(ctx context.Context, prefix string) (map[string]string, error)
- func (m *MockedEtcdWrapper) Inc(ctx context.Context, pfx string) (string, error)
- func (m *MockedEtcdWrapper) NewSession(ctx context.Context, client *clientv3.Client, ...) (*concurrency.Session, error)
- func (m *MockedEtcdWrapper) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
- func (m *MockedEtcdWrapper) UpdateKV(ctx context.Context, key string, value string) error
- func (m *MockedEtcdWrapper) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEtcdNodeExist = errors.New("etcd: node exist") ErrEtcdValueExist = errors.New("etcd: value exist") ErrEtcdValueNotMatch = errors.New("etcd: value not match") ErrUnexpected = errors.New("etcd: unexpected") )
View Source
var (
DefaultRequestTimeout = 1 * time.Second
)
Functions ¶
func ContainerPath ¶
func LeaseBridgePath ¶
func LeaseGuardPath ¶
func LeaseSessionDir ¶
func LeaseSessionPath ¶
LeaseSessionPath 作为guard lease过期的监控点,在得到新的lease的时候创建,server可以通过不续约让这个节点过期, 这样shardkeeper感知到guard lease被过期,发起shard drop动作,注意
func ServicePath ¶
Types ¶
type EtcdClient ¶
func NewEtcdClient ¶
func NewEtcdClient(endpoints []string) (*EtcdClient, error)
func NewEtcdClientWithClient ¶
func NewEtcdClientWithClient(client *clientv3.Client) *EtcdClient
func (*EtcdClient) CompareAndSwap ¶
func (*EtcdClient) CreateAndGet ¶
func (*EtcdClient) DelKVs ¶
func (w *EtcdClient) DelKVs(ctx context.Context, prefixes []string) error
func (*EtcdClient) Delete ¶
func (w *EtcdClient) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
func (*EtcdClient) Get ¶
func (w *EtcdClient) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
func (*EtcdClient) GetClient ¶
func (w *EtcdClient) GetClient() *EtcdClient
func (*EtcdClient) GetKV ¶
func (w *EtcdClient) GetKV(ctx context.Context, node string, opts []clientv3.OpOption) (*clientv3.GetResponse, error)
func (*EtcdClient) NewSession ¶
func (w *EtcdClient) NewSession(_ context.Context, client *clientv3.Client, opts ...concurrency.SessionOption) (*concurrency.Session, error)
func (*EtcdClient) Put ¶
func (w *EtcdClient) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
type EtcdWrapper ¶
type EtcdWrapper interface { io.Closer GetClient() *EtcdClient GetKV(_ context.Context, node string, opts []clientv3.OpOption) (*clientv3.GetResponse, error) GetKVs(ctx context.Context, prefix string) (map[string]string, error) UpdateKV(ctx context.Context, key string, value string) error DelKV(ctx context.Context, prefix string) error DelKVs(ctx context.Context, prefixes []string) error CreateAndGet(ctx context.Context, nodes []string, values []string, leaseID clientv3.LeaseID) error CompareAndSwap(_ context.Context, node string, curValue string, newValue string, leaseID clientv3.LeaseID) (string, error) Inc(_ context.Context, pfx string) (string, error) NewSession(ctx context.Context, client *clientv3.Client, opts ...concurrency.SessionOption) (*concurrency.Session, error) Ctx() context.Context Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan }
EtcdWrapper 4 unit test etcd的方法已经是通过interface开放出来,这里进行二次封装
type MockedEtcdWrapper ¶
func (*MockedEtcdWrapper) Close ¶
func (m *MockedEtcdWrapper) Close() error
func (*MockedEtcdWrapper) CompareAndSwap ¶
func (*MockedEtcdWrapper) CreateAndGet ¶
func (*MockedEtcdWrapper) Ctx ¶
func (m *MockedEtcdWrapper) Ctx() context.Context
func (*MockedEtcdWrapper) DelKV ¶
func (m *MockedEtcdWrapper) DelKV(ctx context.Context, prefix string) error
func (*MockedEtcdWrapper) DelKVs ¶
func (m *MockedEtcdWrapper) DelKVs(ctx context.Context, prefixes []string) error
func (*MockedEtcdWrapper) Delete ¶
func (m *MockedEtcdWrapper) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
func (*MockedEtcdWrapper) Get ¶
func (m *MockedEtcdWrapper) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
func (*MockedEtcdWrapper) GetClient ¶
func (m *MockedEtcdWrapper) GetClient() *EtcdClient
func (*MockedEtcdWrapper) GetKV ¶
func (m *MockedEtcdWrapper) GetKV(ctx context.Context, node string, opts []clientv3.OpOption) (*clientv3.GetResponse, error)
func (*MockedEtcdWrapper) NewSession ¶
func (m *MockedEtcdWrapper) NewSession(ctx context.Context, client *clientv3.Client, opts ...concurrency.SessionOption) (*concurrency.Session, error)
func (*MockedEtcdWrapper) Put ¶
func (m *MockedEtcdWrapper) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
Click to show internal directories.
Click to hide internal directories.