Commit fde1b715 authored by wangwx's avatar wangwx

fix comment

parent eaa68766
......@@ -93,7 +93,7 @@ func initZookeeperClientPool() {
}
//NewZookeeperClient will create a ZookeeperClient
func NewZookeeperClient(name string, zkAddrs []string, share bool, opts ...ZkClientOption) (*ZookeeperClient, error) {
func NewZookeeperClient(name string, zkAddrs []string, share bool, opts ...zkClientOption) (*ZookeeperClient, error) {
if share {
once.Do(initZookeeperClientPool)
zkClientPool.Lock()
......@@ -144,7 +144,7 @@ func (z *ZookeeperClient) createZookeeperConn() error {
// WithTestCluster sets test cluster for zk Client
func WithTestCluster(ts *zk.TestCluster) Option {
return func(opt *Options) {
return func(opt *options) {
opt.Ts = ts
}
}
......@@ -168,14 +168,14 @@ func NewMockZookeeperClient(name string, timeout time.Duration, opts ...Option)
zkEventHandler: &DefaultHandler{},
}
options := &Options{}
option := &options{}
for _, opt := range opts {
opt(options)
opt(option)
}
// connect to zookeeper
if options.Ts != nil {
ts = options.Ts
if option.Ts != nil {
ts = option.Ts
} else {
ts, err = zk.StartTestCluster(1, nil, nil, zk.WithRetryTimes(40))
if err != nil {
......
......@@ -27,18 +27,18 @@ import (
)
// nolint
type Options struct {
type options struct {
ZkName string
Client *ZookeeperClient
Ts *zk.TestCluster
}
// Option will define a function of handling Options
type Option func(*Options)
type Option func(*options)
// WithZkName sets zk Client name
func WithZkName(name string) Option {
return func(opt *Options) {
return func(opt *options) {
opt.ZkName = name
}
}
......@@ -61,17 +61,17 @@ type ZookeeperClient struct {
Session <-chan zk.Event
}
type ZkClientOption func(*ZookeeperClient)
type zkClientOption func(*ZookeeperClient)
// WithZkEventHandler sets zk Client event
func WithZkEventHandler(handler ZkEventHandler) ZkClientOption {
func WithZkEventHandler(handler ZkEventHandler) zkClientOption {
return func(opt *ZookeeperClient) {
opt.zkEventHandler = handler
}
}
// WithZkEventHandler sets zk Client timeout
func WithZkTimeOut(t time.Duration) ZkClientOption {
// WithZkTimeOut sets zk Client timeout
func WithZkTimeOut(t time.Duration) zkClientOption {
return func(opt *ZookeeperClient) {
opt.Timeout = t
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment