Flask Zookeeper client
The Flask-Zookeeper extension provides support to Zookeeper clusters.
First, install cdumay-rest-client using pip:
pip install flask-zookeeper
Flask-Zookeeper depends, and will install for you, recent versions of Flask and Kazzo. Flask-Zookeeper is compatible with and tested on Python 2.7, 3.4 and 3.5.
Next, add a
FlaskZookeeperClient instance to your code:
from flask import Flask from flask_zookeeper import FlaskZookeeperClient app = Flask(__name__) fzc = FlaskZookeeperClient(app)
You can take a look at tests/test_base.py for more complete example.
You can also take a look at tests/test_blueprint.py for an example using Flask’s application factories and blueprints.
About setting up
Flask-Zookeeper uses additional variables which can be set in the app.config:
KAZOO_HOSTS: Zookeeper quorum server list separated by commas (default:
KAZOO_START_TIMEOUT: Time in seconds to wait for connection to succeed (default:
KAZOO_SESSION_TIMEOUT: The longest to wait for a Zookeeper connection (default:
KAZOO_RETRY: Dict of options to use for retrying the connection to Zookeeper (default:
Zookeeper allow to set ACL. To enable this feature, set
KAZOO_ACL_PASSWORD in the
KAZOO_ACL_USERNAME: Username to use for the ACL.
KAZOO_ACL_PASSWORD: A plain-text password to hash.
KAZOO_ACL_READ: Read permission (default:
KAZOO_ACL_WRITE: Write permission (default:
KAZOO_ACL_CREATE: Create permission (default:
KAZOO_ACL_DELETE: Delete permission (default:
KAZOO_ACL_ADMIN: Admin permission (default:
KAZOO_ACL_ALL: All permissions (default:
You can take a look at tests/test_acl.py for a complete example.
Apache License 2.0
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.