pusher / stronghold

[DEPRECATED] A configuration service | owner: @willsewell
12 stars 1 forks source link

DEPRECATED

stronghold is officially deprecated and unmaintained. It is recommended that users transition to alternatives.

Stronghold, an alternative to etcd

Stronghold is a global distributed key-value store for keeping application configuration. It's a bit like etcd, or the KV module of consul.

Stronghold is client-server. The server is Apache ZooKeeper. The main client is stronghold, which provides an HTTP API to query ZooKeeper. That is what this repository provides. stronghold is designed to run as a local daemon on all hosts in your system, and should be the only way you interact with ZooKeeper. For another layer of indirection, see other client libraries which use the stronghold daemon:

Data model

Stronghold features:

API

Stronghold has an HTTP API with the following resources:

GET /head

Fetches the current version, returned in the body.

GET /versions?at=[ts]

Fetches the revision active at ts.

GET /versions?last=[last]&size=[size]

Fetches information on up to size changes before last (a revision). Returns a JSON array containing one object per change in chronological order. Each has at least the following keys:

GET /versions?first=[first]&limit=[limit]&size=[size]

Fetches information on changes that occur after first and ending at either limit (a revision) or after size changes. The response is in the same form as the previous method. size is optional.

GET /[version]/tree/paths

Returns a JSON list of paths in the hierarchy at version.

 GET /[version]/tree/materialized/[path]

Fetches the materialized JSON for a particular path at version.

 GET /[version]/next/tree/materialized/[path]

Blocks until the materialized JSON for a particular path changes and returns a JSON object containing:

GET /[version]/tree/peculiar/[path]

Fetches the JSON peculiar to a particular path.

 GET /[version]/change

Fetches information on the change immediately before version. Returns a JSON object containing:

POST /[version]/update/[path]

Method used to make an update. The body should contain a JSON object with the following keys:

Build instructions

NB: There is a development mode which is backed by sqlite. This is likely to be simpler. You must still install the zookeeper dependency in order for it to compile.

Installing dependencies (on OSX)

brew install zookeeper
export CPATH=$(brew --prefix zookeeper)/include:$CPATH

Installing dependencies on debian / ubuntu

sudo apt-get install libzookeeper-mt-dev

Building Stronghold

stack build

Initial setup

Configuring zookeeper

Here is a basic local zk config: https://gist.github.com/DanielWaterworth/6ab8d009e6d8e7bfa600

Stronghold initial setup

To initialize the state in zookeeper.

stack exec wipe -- localhost:2181

Invocation

stronghold <port> <zk address>

Running locally, you'll probably want:

stack exec stronghold -- 5040 localhost:2181

or

foreman start

There's also a development mode that uses SQLite for storage instead of zookeeper:

stack exec stronghold -- development 5040 ./data.db