Categorygithub.com/yext/curator
modulepackage
0.0.1-alpha.2
Repository: https://github.com/yext/curator.git
Documentation: pkg.go.dev

# README

Repository is no longer maintained.

We've moved away from Zookeeper and no longer have this project running in our codebase. No community has been established and too many issues have not been resolved in this project. Therefore we have decided to archive this project. We'll keep it on this location for those wanting it as reference but that's it.

What is Curator?

Curator n ˈkyoor͝ˌātər: a keeper or custodian of a museum or other collection - A ZooKeeper Keeper.

curator

What is curator-go?

Curator-go is a Golang porting for Curator, which base on the go-zookeeper.

Getting Started

Learn ZooKeeper

Curator-go users are assumed to know ZooKeeper. A good place to start is ZooKeeper Getting Started Guide

Install Curator-go

$ go get github.com/curator-go/curator

Using Curator

Curator-go is available from github.com. You can easily include Curator-go into your code.

import (
	"github.com/curator-go/curator"
)

Getting a Connection

Curator uses Fluent Style. If you haven't used this before, it might seem odd so it's suggested that you familiarize yourself with the style.

Curator connection instances (CuratorFramework) are allocated from the CuratorFrameworkBuilder. You only need one CuratorFramework object for each ZooKeeper cluster you are connecting to:

curator.NewClient(connString, retryPolicy)

This will create a connection to a ZooKeeper cluster using default values. The only thing that you need to specify is the retry policy. For most cases, you should use:

retryPolicy := curator.NewExponentialBackoffRetry(time.Second, 3, 15*time.Second)

client := curator.NewClient(connString, retryPolicy)

client.Start()
defer client.Close()

The client must be started (and closed when no longer needed).

Calling ZooKeeper Directly

Once you have a CuratorFramework instance, you can make direct calls to ZooKeeper in a similar way to using the raw ZooKeeper object provided in the ZooKeeper distribution. E.g.:

client.Create().ForPathWithData(path, payload)

The benefit here is that Curator manages the ZooKeeper connection and will retry operations if there are connection problems.

Recipes

Distributed Lock

lock := curator.NewInterProcessMutex(client, lockPath)

if ( lock.Acquire(maxWait, waitUnit) )
{
    defer lock.Release()

    // do some work inside of the critical section here
}

Leader Election

listener := curator.NewLeaderSelectorListener(func(CuratorFramework client) error {
    // this callback will get called when you are the leader
    // do whatever leader work you need to and only exit
    // this method when you want to relinquish leadership
}))

selector := curator.NewLeaderSelector(client, path, listener)
selector.AutoRequeue()  // not required, but this is behavior that you will probably expect
selector.Start()

Examples

This module contains example usages of various Curator features. Each directory in the module is a separate example.

  • leader Example leader selector code
  • cache Example PathChildrenCache usage
  • locking Example of using InterProcessMutex
  • discovery Example usage of the Curator's ServiceDiscovery
  • framework A few examples of how to use the CuratorFramework class

See the examples source repo for each example.

Components

  • Recipes Implementations of some of the common ZooKeeper "recipes". The implementations are built on top of the Curator Framework.
  • Framework The Curator Framework is a high-level API that greatly simplifies using ZooKeeper. It adds many features that build on ZooKeeper and handles the complexity of managing connections to the ZooKeeper cluster and retrying operations.
  • Utilities Various utilities that are useful when using ZooKeeper.
  • Client A replacement for the bundled ZooKeeper class that takes care of some low-level housekeeping and provides some useful utilities.
  • Errors How Curator deals with errors, connection issues, recoverable exceptions, etc.

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
Recursively deletes children of a node.
Apply the namespace to the given path.
Given a full path, return the node name.
Given a parent and a child node, join them in the given path.
Make sure all the nodes in the path are created.
No description provided by the author
Create a new client with default session timeout and default connection timeout.
Create a new client.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewUnhandledErrorListener creates an UnhandledErrorListener with given callback.
No description provided by the author
No description provided by the author
No description provided by the author
Given a full path, return the the individual parts, without slashes.
Validate the provided znode path string.

# Constants

No description provided by the author
CuratorFramework.GetChildren() -> Err(), Path(), Stat(), Children().
Event sent when client is being closed.
Sent for the first successful connection to the server.
CuratorFramework.Create() -> Err(), Path(), Data().
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CuratorFramework.Delete() -> Err(), Path().
No description provided by the author
No description provided by the author
CuratorFramework.CheckExists() -> Err(), Path(), Stat().
No description provided by the author
CuratorFramework.GetACL() -> Err(), Path().
CuratorFramework.GetData() -> Err(), Path(), Stat(), Data().
Start() has not yet been called.
The connection is confirmed to be lost.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
The connection has gone into read-only mode.
A suspended, lost, or read-only connection has been re-established.
CuratorFramework.SetACL() -> Err(), Path().
CuratorFramework.SetData() -> Err(), Path(), Stat().
Start() has been called.
No description provided by the author
Close() has been called.
There has been a loss of connection.
CuratorFramework.Sync() -> Err(), Path().
No description provided by the author
No description provided by the author
Watchable.UsingWatcher() -> WatchedEvent().

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
Retry policy that retries a set number of times with increasing sleep time between retries.
Standard ensemble provider that wraps a fixed connection string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Retry policy that retries a max number of times.
A retry policy that retries only once.
A retry policy that retries until a given amount of time elapses.
No description provided by the author
Holds the result of one transactional operation.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author
A Closeable is a source or destination of data that can be closed.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
A super set of all the various Zookeeper events/background methods.
Zookeeper framework-style client.
No description provided by the author
Receives notifications about errors and background events.
A wrapper around Zookeeper that takes care of some low-level housekeeping.
No description provided by the author
Abstraction that provides the ZooKeeper connection string.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Abstracts a listenable object.
Mechanism to perform an operation on Zookeeper that is safe against disconnections and "recoverable" errors.
Abstracts the policy to use when retrying connections.
Abstraction for retry policies to sleep.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Mechanism for timing methods and recording counters.
Transactional/atomic operations.
Syntactic sugar to make the fluent interface more readable.
No description provided by the author
No description provided by the author
No description provided by the author
Adds commit to the transaction interface.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Allocate a new ZooKeeper connection.

# Type aliases

No description provided by the author
Called when the async background operation completes.
No description provided by the author
No description provided by the author
No description provided by the author
Transaction operation types.
No description provided by the author
No description provided by the author