Documentation ¶
Index ¶
- func CreateNode(t *testing.T, zkConn *szk.Conn, path string, obj interface{})
- func CreateNodes(t *testing.T, zkConn *szk.Conn, pathTuples []PathTuple)
- type Client
- type DebugLogger
- type Lock
- type PathTuple
- type PooledClient
- func (c *PooledClient) AcquireLock(ctx context.Context, path string) (Lock, error)
- func (c *PooledClient) Children(ctx context.Context, path string) ([]string, *szk.Stat, error)
- func (c *PooledClient) Close() error
- func (c *PooledClient) Create(ctx context.Context, path string, data []byte, sequential bool) error
- func (c *PooledClient) CreateJSON(ctx context.Context, path string, obj interface{}, sequential bool) error
- func (c *PooledClient) Exists(ctx context.Context, path string) (bool, *szk.Stat, error)
- func (c *PooledClient) Get(ctx context.Context, path string) ([]byte, *szk.Stat, error)
- func (c *PooledClient) GetJSON(ctx context.Context, path string, obj interface{}) (*szk.Stat, error)
- func (c *PooledClient) Set(ctx context.Context, path string, data []byte, version int32) (*szk.Stat, error)
- func (c *PooledClient) SetJSON(ctx context.Context, path string, obj interface{}, version int32) (*szk.Stat, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNode ¶
CreateNode creates a single node at the argument path. For testing purposes only.
Types ¶
type Client ¶
type Client interface { // Read-only operations Get(ctx context.Context, path string) ([]byte, *szk.Stat, error) GetJSON(ctx context.Context, path string, obj interface{}) (*szk.Stat, error) Children(ctx context.Context, path string) ([]string, *szk.Stat, error) Exists( ctx context.Context, path string, ) (bool, *szk.Stat, error) // Write operations Create(ctx context.Context, path string, data []byte, sequential bool) error CreateJSON(ctx context.Context, path string, obj interface{}, sequential bool) error Set( ctx context.Context, path string, data []byte, version int32, ) (*szk.Stat, error) SetJSON( ctx context.Context, path string, obj interface{}, version int32, ) (*szk.Stat, error) // Lock operations AcquireLock(ctx context.Context, path string) (Lock, error) Close() error }
Client exposes some common, zk operations. Unlike the underlying samuel zk client, it allows passing a context into most calls.
type DebugLogger ¶ added in v1.3.0
type DebugLogger struct{}
DebugLogger is a logger that satisfies the szk.Logger interface.
func (*DebugLogger) Printf ¶ added in v1.3.0
func (l *DebugLogger) Printf(format string, args ...interface{})
Printf sends samuel zk log messages to logrus at the debug level.
type Lock ¶
type Lock interface {
Unlock() error
}
Lock is a lock interface that's satified by the samuel zk Lock struct.
type PathTuple ¶
type PathTuple struct { Path string Obj interface{} }
PathTuple is a <path, object> combination used for generating nodes in zk. For testing purposes only.
type PooledClient ¶
type PooledClient struct {
// contains filtered or unexported fields
}
PooledClient is a Client implementation that uses a pool of connections instead of a single one for read-only operations. It can be subtantially faster than the base samuel client, particularly when getting zookeeper nodes from multiple goroutines.
func NewPooledClient ¶
func NewPooledClient( zkAddrs []string, timeout time.Duration, logger szk.Logger, poolSize int, readOnly bool, ) (*PooledClient, error)
NewPooledClient returns a new PooledClient instance.
func (*PooledClient) AcquireLock ¶
AcquireLock tries to acquire a lock using the argument zk path.
func (*PooledClient) Close ¶
func (c *PooledClient) Close() error
Close closes the current client and frees the associated resources.
func (*PooledClient) Create ¶
func (c *PooledClient) Create( ctx context.Context, path string, data []byte, sequential bool, ) error
Create adds a new node at the argument zk path.
func (*PooledClient) CreateJSON ¶
func (c *PooledClient) CreateJSON( ctx context.Context, path string, obj interface{}, sequential bool, ) error
CreateJSON creates a new node at the argument zk path using the JSON-marshalled contents of the argument object.
func (*PooledClient) GetJSON ¶
func (c *PooledClient) GetJSON( ctx context.Context, path string, obj interface{}, ) (*szk.Stat, error)
GetJSON unmarshals the JSON content at the argument zk path into an object.