#postgresql #zookeeper #connection-pool #pool #replication #resolver #primary

cueball-manatee-primary-resolver

An implementation of the cueball Resolver trait that is specific to the Joyent manatee project. It queries a zookeeper cluster to determine the PostgreSQL replication primary from a set of PostgreSQL replication peers.

2 unstable releases

0.5.1 May 19, 2020
0.3.0 Jan 8, 2020

#2557 in Database interfaces

MPL-2.0 license

175KB
3K SLoC

cueball-manatee-primary-resolver

About

This is an implementation of the cueball Resolver trait that provides a list of backends for use by the connection pool. See the cueball documentation for more information.

This resolver is specific to the Joyent manatee project. It queries a zookeeper cluster to determine the PostgreSQL replication primary from a set of PostgreSQL replication peers.

Useful tools

The manatee-echo-resolver binary, in /rust-cueball/tools/, runs a manatee primary resolver and prints its logging, as well as messages received over the cueball channel, to standard out. This is useful for ad-hoc testing. Here's how to build and run:

# Note that these paths are relative to the repository root
$ cd rust-cueball

$ cargo build

$ ./target/debug/echo-resolver --help

Test suite

Prerequisites

The test suite requires a running ZooKeeper instance with the following properties:

  • ZooKeeper is accessible on localhost at port 2181.
  • ZooKeeper is running as an SMF service.

The easiest way to meet both of these criteria is to run the test suite on Joyent SmartOS and install ZooKeeper in your test zone via pkgsrc.

The ZooKeeper instance does not require any other setup ahead of time -- the test suite will handle the creation and deletion of test nodes with mock data.

Running the test suite

To run the test suite, run cargo test.

The amount of log output may be distracting. You can quell this by setting the RESOLVER_LOG_LEVEL to something high, perhaps critical. The default log level is info. If you do want to look at the log output, you may want to pipe it into bunyan for readability. Because the tests run in parallel where it is safe to do so, their log output will occasionally interleave, rendering it unparseable. If this is a nuisance, you can run the tests consecutively using the instructions here.

Dependencies

~13MB
~249K SLoC