Documentation ¶
Overview ¶
Package store 存储发号进度
Index ¶
Examples ¶
Constants ¶
const ( // DefaultConnectTimeout is the default timeout to establish a connection to // a ZooKeeper node. DefaultConnectTimeout = 2 * time.Second // DefaultSessionTimeout is the default timeout to keep the current // ZooKeeper session alive during a temporary disconnect. DefaultSessionTimeout = 5 * time.Second )
Variables ¶
var ( // ErrEtcdFail 从etcd中Range出错 ErrEtcdFail = errors.New("etcd save error") // ErrEtcdNotFound 从etcd中获取单个key出错 ErrEtcdNotFound = errors.New("etcd key not found") )
var ( DefaultACL = zk.WorldACL(zk.PermAll) ErrInvalidCredentials = errors.New("invalid credentials provided") ErrZKFail = errors.New("zk save error") )
DefaultACL is the default ACL to use for creating znodes.
var (
ErrDBNotExists = errors.New("zk: db does not exist")
)
Functions ¶
This section is empty.
Types ¶
type Etcd ¶
A Etcd 使用etcd 存储发号元数据
type Option ¶
type Option func(*zkConfig) error
Option functions enable friendly APIs.
func ConnectTimeout ¶
ConnectTimeout returns an Option specifying a non-default connection timeout when we try to establish a connection to a ZooKeeper server.
func Credentials ¶
Credentials returns an Option specifying a user/password combination which the client will use to authenticate itself with.
func EventHandler ¶
EventHandler returns an Option specifying a callback function to handle incoming zk.Event payloads (ZooKeeper connection events).
func Payload ¶
Payload returns an Option specifying non-default data values for each znode created by CreateParentNodes.
func SessionTimeout ¶
SessionTimeout returns an Option specifying a non-default session timeout.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
A Redis 使用redis作存储
type Store ¶
type Store interface { // Range 获取数据,传入数据中心ID,业务唯一ID和获取连续的区间大小,得到连续的最大ID和错误[id-size, id) Range(ctx context.Context, dataCenter uint8, db, table string, size int64) (id int64, err error) // Init 这里可以完成初始化方法,保证服务的可用 Init(dataCenter uint8) error BlockDB(dataCenter uint8, db string) bool // Ping 检查连接 Ping(ctx context.Context) error }
A Store 存储接口