Good evening!
I submit for your evaluation and reasoned feedback a library I've been working on to provide a set of convergent replicated data types to Clojure and ClojureScript:
https://github.com/aredington/schism[com.holychao/schism "0.1.0"]
Schism provides convergent collections for sets, vectors, lists, and maps, along with edn readers and writers out of the gate. My intent is to provide you with all the tools necessary to replicate a collection across two or more computing nodes.
Replication is a hard problem, so there are a few caveats to these tools as I provide them:
- You must identify nodes within your cluster. You may choose to identify nodes with a random UUID, in which case schism will help you to do so. Node identifiers must be clojure serializable data.
- Schism purposefully avoids carrying around a monotonically increasing historical collection of data about deleted entries. Consequently there are some ambiguities during convergence that may not exactly mirror local modification.
- Schism is only solving the problem of synchronizing two in memory sets. Maintaining identity of those two sets, tracking state changes, and long term durability are responsibilities left to the schism user.
Schism collections are persistent collections, so you should feel free to work with them as a drop in replacement for a function which would work against a Clojure collection. The usual utilities such as conj, assoc, dissoc, disj, and rest are pure functions which will return you derived copies, implicitly soing the convergence bookkeeping necessary in the background. As you work with it, schism will maintain node and timestamp information, with the goal of convergence providing the same result as if all previous invocations had occurred on one local collection in memory. Schism's requirements are your expectations of a Clojure collection, so hash, =, and support for meta are all included, as well as many other functions defined against Clojure's own collections. Particularly with hash and =, you can expect a schism collection to return the same hashcode as its Clojure equivalent, and to determine equality in the same way as its Clojure equivalent would.
I've built schism in the absence of a direct itch to scratch with it. Should you find that it betrays your expectations of Clojure collections, I'd greatly appreciate a bug report and will work to correct schism quickly.
I hope that it assists you in solving your own problems.
-Alex