Not Logged In

pyrainer 0.15

Rainer helps you deal with namespaces of versioned key/value pairs called "commits". It includes a variety of APIsthat can collectively provide a full audit trail, concurrency-safe updates, local caching, immediate clusternotifications, and easy client integration. The Rainer APIs can be used independently, or they can be used together aspart of a powerful configuration management system.

## Commits

Commits have the attributes:

- Key, which is a String.- Payload, which can be an arbitrary type. Think of this like a short document.- Version, which must increase by one with each commit.- Author, the entity that created the commit.- Comment, some free-form string describing the commit.- Mtime, the timestamp when the commit was created.

Each key's commits are separate from every other key's commits, and are versioned independently. In particular,there is no concept of a global namespace version.

Your value type must be deserializable, so you need to provide a KeyValueDeserialization for it. You do not need toprovide a serializer, because your values will never be serialized by Rainer. Commits are always built from raw bytesand those bytes are stored verbatim. If the documents will be edited by humans, this makes it easy to use formatswith comments, any whitespace you like, and so on.

## Long-term journaled storage

The CommitStorage trait represents a key/value store that retains every version of every commit. Itsdefault implementation is DbCommitStorage, which is backed by an RDBMS.

// Which, for example, you can use to update an AtomicReference:val ref = new AtomicReference[Map[String, Commit[ValueType]]]val c = mirror.changes.register(Witness(ref))

// When no longer interested in updates:Await.result(c.close())```

### Using CommitKeeper with CommitStorage

Combining a CommitStorage with a CommitKeeper is a common pattern used for managing configuration of a cluster ofmachines. This setup can provide full-history journaled updates in an RDBMS, coupled with low latency notificationsthrough ZooKeeper. The idea is to do all of your saves through a keeperPublishing CommitStorage (which will updateZooKeeper any time you save something) and to do your reads through a mirror provided by a CommitKeeper. To preventinopportune crashes or out of band ZooKeeper modifications from causing ZooKeeper to become out of sync, you can alsouse an autoPublisher to periodically push any unpushed updates from your storage. This can all be done with somethinglike:

You can use CommitKeeper by itself, too, without any backing journaled storage. Just call ```keeper.save(commit)``` topublish new commits, and don't use the autoPublisher. Everything else will work normally, including gets and mirrors.

## HTTP server

You can add a RainerServlet to your Jetty-based server to gain a nice HTTP API to your CommitStorage. The API canbe used like this with any HTTP client: