Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (65 sloc) 2 KB


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:

  [{:host node2 :port 5555}
   {:host node3 :port 5555}])

Create an Atomix client for a set of servers:

  [{: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")


API docs are available here.


Copyright © 2015-2016 Atomix contributors

Distributed under the Eclipse Public License either version 1.0