All Projects → atomix → trinity

atomix / trinity

Licence: EPL-1.0 license
A sweet Clojure API for Atomix

Programming Languages

clojure
4091 projects
shell
77523 projects

trinity

Clojars license

A sweet Clojure API for Atomix.

Core Usage

(require [trinity.core :as trinity])

Create an Atomix replica specifying local port to listen on and a set of remote servers that the replica should connect to:

(trinity/replica 
  5555 
  [{:host node2 :port 5555}
   {:host node3 :port 5555}])

Create an Atomix client for a set of servers:

(trinity/client
  [{:host node1 :port 5555}
   {:host node2 :port 5555}
   {:host node3 :port 5555}])

Open an Atomix client or replica:

(trinity/open! atomix)

Close an Atomix client or replica:

(trinity/close! atomix)

Note: Trinity functions operate sychronously by default, but many functions have async counterparts such as open-async! which return CompletableFuture.

Using Atomix Resources

Distributed Value

Get a distributed value for some resource name:

(def register 
  (trinity/get-value client "register"))

Operate on the value:

(require '[trinity.distributed-value :as dvalue])

(dvalue/get register)
(dvalue/set! register "value")
(dvalue/cas! register "expected" "updated")

Distributed Map

Get a distributed map for some resource name:

(def cache 
  (trinity/get-map client "cache"))

Operate on the map:

(require '[trinity.distributed-map :as dmap])

(dmap/get cache "key")
(dvalue/put! cache "key" "value")
(dvalue/remove! cache "key")

Docs

API docs are available here.

License

Copyright © 2015-2016 Atomix contributors

Distributed under the Eclipse Public License either version 1.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].