Documentation ¶
Index ¶
- func ForEachNode(fullPath string, node ZNode, do func(fullPath string, n ZNode) error) error
- func UnmarshalYAML(yml []byte) (map[string]ZNode, error)
- type ClientGetter
- type ClusterGetter
- type ClusterOperation
- type NodeAction
- type NodeActionFunc
- type ZNode
- type ZNodeAssertion
- type ZkCluster
- func (c *ZkCluster) Connect(idx int) (*enhanced.Client, error)
- func (c *ZkCluster) ConnectAll() (*enhanced.Client, error)
- func (c *ZkCluster) ConnectionString() string
- func (c *ZkCluster) DoCreate(yml []byte) error
- func (c *ZkCluster) DoDelete(yml []byte) error
- func (c *ZkCluster) DoUpdate(yml []byte) error
- func (c *ZkCluster) Stop() error
- type ZkEnv
- func (z *ZkEnv) Client() *enhanced.Client
- func (z *ZkEnv) ConnectionString() string
- func (z *ZkEnv) NewClient() *enhanced.Client
- func (z *ZkEnv) NewClientTimeout(timeout time.Duration) *enhanced.Client
- func (z *ZkEnv) Start() *ZkEnv
- func (z *ZkEnv) Stop()
- func (z *ZkEnv) With(fn func(env *ZkEnv))
- func (z *ZkEnv) Zk() *ZkCluster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachNode ¶
ForEachNode calls do with all children nodes and itself.
Types ¶
type ClientGetter ¶
ClientGetter represents a getter of *enhanced.Client.
type ClusterGetter ¶
type ClusterGetter interface {
Zk() *ZkCluster
}
ClusterGetter represents a getter of *ZkCluster.
type ClusterOperation ¶
type ClusterOperation struct { ClusterGetter // contains filtered or unexported fields }
ClusterOperation does CUD operations of ZkCluster with NoError assertion.
func (*ClusterOperation) MustCreate ¶
func (o *ClusterOperation) MustCreate(yml string)
MustCreate calls DoCreate on inner ZkCluster with NoError assertion.
func (*ClusterOperation) MustDelete ¶
func (o *ClusterOperation) MustDelete(yml string)
MustDelete calls DoDelete on inner ZkCluster with NoError assertion.
func (*ClusterOperation) MustUpdate ¶
func (o *ClusterOperation) MustUpdate(yml string)
MustUpdate calls DoUpdate on inner ZkCluster with NoError assertion.
type NodeAction ¶
type NodeAction struct {
// contains filtered or unexported fields
}
NodeAction contains NodeActionFunc(s) that are used while traversing a tree.
func StartNewNodeAction ¶
func StartNewNodeAction(c *ZkCluster) (*NodeAction, error)
StartNewNodeAction create then starts NodeAction on given ZkCluster.
func (*NodeAction) DoCreate ¶
func (a *NodeAction) DoCreate(fullPath string, node ZNode) error
DoCreate is a NodeActionFunc which creates a ZNode with its parents.
func (*NodeAction) DoDelete ¶
func (a *NodeAction) DoDelete(fullPath string, node ZNode) error
DoDelete is a NodeActionFunc which deletes a ZNode with its children.
type NodeActionFunc ¶
NodeActionFunc represents an action to a ZNode.
type ZNode ¶
type ZNode struct { Value *string `yaml:"value,omitempty"` Children map[string]ZNode `yaml:"children,omitempty"` }
ZNode represents a ZooKeeper znode in YAML.
type ZNodeAssertion ¶
type ZNodeAssertion struct { ClientGetter // contains filtered or unexported fields }
ZNodeAssertion contains helpers of ZNode assertion.
func (*ZNodeAssertion) AssertNoZNode ¶
func (a *ZNodeAssertion) AssertNoZNode(pathes ...string)
AssertNoZNode asserts given ZNodes do not exist.
func (*ZNodeAssertion) AssertZNode ¶
func (a *ZNodeAssertion) AssertZNode(pathes ...string)
AssertZNode asserts given ZNodes exist.
func (*ZNodeAssertion) AssertZNodeWithValue ¶
func (a *ZNodeAssertion) AssertZNodeWithValue(path, value string)
AssertZNodeWithValue asserts a ZNode with given value.
type ZkCluster ¶
type ZkCluster struct { *zk.TestCluster // contains filtered or unexported fields }
ZkCluster is a managed ZooKeeper cluster for testing purpose.
func StartZkCluster ¶
StartZkCluster starts a managed ZooKeeper with given size of nodes.
func (*ZkCluster) ConnectAll ¶
ConnectAll starts a client to all servers.
func (*ZkCluster) ConnectionString ¶
ConnectionString returns connection string like: 127.0.0.1:21810,127.0.0.1:21811
type ZkEnv ¶
type ZkEnv struct { ZNodeAssertion ClusterOperation // contains filtered or unexported fields }
ZkEnv should only be used in TESTING. It starts a managed ZooKeeper cluster before testing and stops it after.
func (*ZkEnv) Client ¶
Client returns a client to ZooKeeper cluster. NOTE: Don't close the client, it will be closed by .Stop()
func (*ZkEnv) ConnectionString ¶
ConnectionString returns the connection string of ZooKeeper cluster.
func (*ZkEnv) NewClientTimeout ¶
NewClientTimeout creates a client to ZooKeeper cluster and wait until it gets connected within given timeout.