Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rricard/consens
Distributed clojure data structures through Paxos
https://github.com/rricard/consens
Last synced: about 14 hours ago
JSON representation
Distributed clojure data structures through Paxos
- Host: GitHub
- URL: https://github.com/rricard/consens
- Owner: rricard
- License: epl-1.0
- Created: 2014-12-30T00:06:57.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-03T10:48:55.000Z (almost 10 years ago)
- Last Synced: 2023-08-03T20:09:58.101Z (over 1 year ago)
- Language: Clojure
- Size: 238 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# consens
Consens is a library/server cluster for distributed consensus. It doesn't do much right now but we are already capable to boot up a paxos cluster.
## Installation
Download from https://github.com/rricard/consens.
## Usage
### Paxos server node
For now, everything is in development so everything will pass through leiningen.
Ok, so let's start a single node (which is pointless...)
$ lein ring server
Let's store some keys inside and retrieve them ! (later this will be supported by a nice Clojure API too !)
$ curl -XPUT localhost:3000/mykey -d mydata
created
$ curl -XGET localhost:3000/mykey
mydataAt this point, nothing to be amazed !
Let's restart all of that by spinning 3 instances:
# in tty1
$ CLUSTER=http://localhost:4000,http://localhost:5000 lein ring server
# in tty2
$ CLUSTER=http://localhost:3000,http://localhost:5000 PORT=4000 lein ring server
# in tty3
$ CLUSTER=http://localhost:3000,http://localhost:4000 PORT=5000 lein ring serverNow let's write on one node and see it on the other nodes:
$ curl -XPUT localhost:4000/mykey -d mydata
created
$ curl -XGET localhost:3000/mykey
mydata
$ curl -XGET localhost:4000/mykey
mydata
$ curl -XGET localhost:5000/mykey
mydataYou can disconnect one node, write and still see a consensus. Disconnect the majority of the nodes, the consensus goes away !
If a node is disconnected, you can make him catch up with the cluster with JOIN:
# tty3
^C
$ CLUSTER=http://localhost:3000,http://localhost:4000 PORT=5000 JOIN=true lein ring serverJOIN will try to catch up with first node in the cluster list. JOIN will fail if the this node is unavailable too !
If all the nodes gets disconnected, well, you lose your data. So here's my advice for now: **DON'T YOU EVEN TRY TO USE THIS IN ANY KIND OF PRODUCTION SYSTEM**. Of course, I want to make it better but if you still want to put it in production for whatever crazy reason: **THIS IS MY FIRST CLOJURE PROJECT**.
But that doesn't keep you from playing with it and even helping me making it a real, usable system ! PRs are welcome !
### Roadmap
- **TEST THE HANDLERS**, yeah that's bad ! The core funcs are tested but the whole system is not. I don't know how to tackle the problem right now anyway, I have to think a little bit more about it...
- Simple, side-effect free, Client API. With futures if possible.
- Try to integrate it with existing clojure protocols, I'll need to read more literature on that before I think ...
- Oh ! and ... LOAD TESTING !## License
Copyright © 2014-2015 Robin Ricard
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.