Documentation ¶
Index ¶
- func CreateDefaultClient(config *Config) error
- func NewEtcdClient(ctx context.Context, cfg *Config, zapLoggerConf *zap.Config) (cli *clientv3.Client, err error)
- func NewStarter() *starter
- func XClient() *clientv3.Client
- func XFClient(f func(c *clientv3.Client) error) error
- type Config
- type EtcdCommon
- func (c *EtcdCommon) Get(key string) (*clientv3.GetResponse, error)
- func (c *EtcdCommon) GetCount(key string) (*clientv3.GetResponse, error)
- func (c *EtcdCommon) GetWithContext(ctx context.Context, key string) (*clientv3.GetResponse, error)
- func (c *EtcdCommon) GetWithPrefix(ctx context.Context, key string) (*clientv3.GetResponse, error)
- func (c *EtcdCommon) Put(key, value string) error
- func (c *EtcdCommon) PutWithContext(ctx context.Context, key, value string) error
- func (c *EtcdCommon) PutWithLease(ctx context.Context, key, value string, ttl int64) (clientv3.LeaseID, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEtcdClient ¶
func NewStarter ¶
func NewStarter() *starter
Types ¶
type Config ¶
type Config struct { Endpoints []string // etcd服务节点列表 Username string // 用户名 Password string // 用户密码 PermitWithoutStream bool // 如为true则设置后将允许客户端在没有任何活动流(RPC)的情况下向服务器发送keepalive ping。 RejectOldCluster bool // 如果true,则拒绝针对过时的群集创建客户端。 AutoSyncInterval uint // 更新其最新成员端点的时间间隔。 0禁用自动同步。 默认情况下,自动同步被禁用。 DialTimeout uint // 未能建立连接超时。 DialKeepAliveTime uint // 客户端ping服务器以查看传输是否活动的时间。 DialKeepAliveTimeout uint // 客户端等待keep-alive探测响应的时间。如果此时未收到响应,则连接将关闭。 MaxCallRecvMsgSize int // 客户端响应接收限制。如果为0,则默认为“math.MaxInt32”,因为范围响应可能会明显超过请求发送限制。请确保“MaxCallRecvMsgSize”>=服务器端默认发送/接收限制。(--etcd的“max request bytes”标志或“embed.Config.MaxRequestBytes”)。 MaxCallSendMsgSize int // 客户端请求发送限制(字节)。如果为0,则默认为2.0 MiB(2*1024*1024)。请确保“MaxCallSendMsgSize”<服务器端默认发送/接收限制。 (“--max request bytes”标记为etcd或“embed.Config.MaxRequestBytes”)。 }
type EtcdCommon ¶
type EtcdCommon struct {
// contains filtered or unexported fields
}
func XEtcdCommon ¶
func XEtcdCommon() *EtcdCommon
func (*EtcdCommon) GetCount ¶
func (c *EtcdCommon) GetCount(key string) (*clientv3.GetResponse, error)
获取该键包含子健的个数
func (*EtcdCommon) GetWithContext ¶
func (c *EtcdCommon) GetWithContext(ctx context.Context, key string) (*clientv3.GetResponse, error)
获取键值携带context
func (*EtcdCommon) GetWithPrefix ¶
func (c *EtcdCommon) GetWithPrefix(ctx context.Context, key string) (*clientv3.GetResponse, error)
获取该键下所有的子健值
func (*EtcdCommon) PutWithContext ¶
func (c *EtcdCommon) PutWithContext(ctx context.Context, key, value string) error
设置键值携带context
func (*EtcdCommon) PutWithLease ¶
func (c *EtcdCommon) PutWithLease(ctx context.Context, key, value string, ttl int64) (clientv3.LeaseID, error)
使用租约设置键值
Click to show internal directories.
Click to hide internal directories.