Using Client
IZooKeeperClient
exposes a bunch of methods for manipulations with ZooKeeper nodes along with some session-related properties. With it, you can create and delete nodes, retrieve and change contents of nodes, probe nodes existence and get all the children of given node. All methods of client are thread-safe. A single ZooKeeperClient instance can (and should!) be shared between multiple consumers.
Let's take a look at CreateAsync method as an example. It accepts a request model object as its argument that has two required and some optional arguments:
Inspecting a Result
Any operation returns a complex result:
Any result type is derived from the ZooKeeperResult
that has a bunch of additional methods that help to analyze an outcome of operation. For example, let's throw an exception if error is a non-retryable network failure:
Extension Methods
If you do not need additional parameters for your request, a set of concise extension methods would come in handy:
For any asynchronous method there's also a synchronous extension that simply does .GetAwaiter().GetResult()
:
Last updated