Skip to content

Commit cd70087

Browse files
committed
Update readme
1 parent 2d8ee0e commit cd70087

File tree

1 file changed

+192
-5
lines changed

1 file changed

+192
-5
lines changed

readme.adoc

Lines changed: 192 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
== xtdb-tarantool
1+
image:https://img.shields.io/github/license/sultanov-team/xtdb-tarantool[license,link=license]
2+
image:https://codecov.io/gh/sultanov-team/xtdb-tarantool/branch/master/graph/badge.svg?token=3VpsOfOpH5)[codecov,link=https://codecov.io/gh/sultanov-team/xtdb-tarantool]
3+
image:https://github.com/sultanov-team/xtdb-tarantool/workflows/build/badge.svg[build]
24

3-
XTDB module allows you to use Tarantool (in-memory computing platform).
5+
image:https://img.shields.io/clojars/v/team.sultanov/xtdb-tarantool.svg[clojars,link=https://clojars.org/team.sultanov/xtdb-tarantool]
6+
7+
== XTDB Tarantool
8+
9+
https://www.xtdb.com[XTDB] module allows you to use https://www.tarantool.io/[Tarantool] (in-memory computing platform).
410

511
**Status: ** Alpha.
612
The design and prototyping stage.
@@ -12,17 +18,198 @@ Add the following dependency in your project:
1218
[source,clojure]
1319
----
1420
;; project.clj or build.boot
15-
[team.sultanov/xtdb-tarantool "RELEASE"]
21+
[team.sultanov/xtdb-tarantool "0.1.56-SNAPSHOT"]
1622
1723
;; deps.edn
18-
team.sultanov/xtdb-tarantool {:mvn/version "RELEASE"}
24+
team.sultanov/xtdb-tarantool {:mvn/version "0.1.56-SNAPSHOT"}
25+
----
26+
27+
=== Usage
28+
29+
*Requirements*
30+
31+
First you need to configure the Tarantool:
32+
33+
- link:docker-compose.yaml[Docker compose]
34+
- link:src/main/tarantool/xtdb.lua[Tarantool configuration]
35+
36+
[source,clojure]
37+
----
38+
;; src/develop/clojure/xtdb/tarantool/example.clj
39+
40+
(ns xtdb.tarantool.example
41+
(:require
42+
[clojure.tools.namespace.repl :as tools.repl]
43+
[integrant.core :as ig]
44+
[integrant.repl :as ig.repl]
45+
[integrant.repl.state :as ig.repl.state]
46+
[xtdb.api :as xt]
47+
[xtdb.tarantool :as tnt])
48+
(:import
49+
(java.io
50+
Closeable)
51+
(java.time
52+
Duration)))
53+
54+
55+
(tools.repl/set-refresh-dirs "src/dev/clojure")
56+
57+
58+
(defn config
59+
[]
60+
{::xtdb-tnt {::tnt-client {:xtdb/module 'xtdb.tarantool/->tnt-client
61+
:username "root"
62+
:password "root"}
63+
:xtdb/tx-log {:xtdb/module 'xtdb.tarantool/->tx-log
64+
:tnt-client ::tnt-client
65+
:poll-wait-duration (Duration/ofSeconds 5)}
66+
:xtdb.http-server/server {:read-only? true
67+
:server-label "[xtdb-tarantool] Console Demo"}}})
68+
69+
70+
(defn prep
71+
[]
72+
(ig.repl/set-prep! config))
73+
74+
75+
(defn go
76+
[]
77+
(prep)
78+
(ig.repl/go))
79+
80+
81+
(def halt ig.repl/halt)
82+
(def reset-all ig.repl/reset-all)
83+
84+
85+
(defn system
86+
[]
87+
ig.repl.state/system)
88+
89+
90+
(defmethod ig/init-key ::xtdb-tnt [_ config]
91+
(xt/start-node config))
92+
93+
94+
(defmethod ig/halt-key! ::xtdb-tnt [_ ^Closeable node]
95+
(tnt/close node))
96+
97+
98+
(comment
99+
100+
(reset-all)
101+
(halt)
102+
(go)
103+
;; open http://localhost:3000/
104+
105+
106+
(def node
107+
(::xtdb-tnt (system)))
108+
109+
110+
(xt/submit-tx node [[::xt/put {:xt/id "xtdb-tarantool", :user/email "ilshat@sultanov.team"}]])
111+
;; => #:xtdb.api{:tx-id 1, :tx-time #inst"2021-12-04T01:27:15.641-00:00"}
112+
113+
114+
(xt/q (xt/db node) '{:find [e]
115+
:where [[e :user/email "ilshat@sultanov.team"]]})
116+
;; => #{["xtdb-tarantool"]}
117+
118+
119+
(xt/q (xt/db node)
120+
'{:find [(pull ?e [*])]
121+
:where [[?e :xt/id "xtdb-tarantool"]]})
122+
;; => #{[{:user/email "ilshat@sultanov.team", :xt/id "xtdb-tarantool"}]}
123+
124+
125+
(def history (xt/entity-history (xt/db node) "xtdb-tarantool" :desc {:with-docs? true}))
126+
;; => [#:xtdb.api{:tx-time #inst"2021-12-04T01:31:14.080-00:00",
127+
;; :tx-id 2,
128+
;; :valid-time #inst"2021-12-04T01:31:14.080-00:00",
129+
;; :content-hash #xtdb/id"d0eb040d39fbdaa8699d867bc9fb9aa244b8e154",
130+
;; :doc {:user/email "ilshat@sultanov.team", :xt/id "xtdb-tarantool"}}]
131+
132+
133+
(->> (map ::xt/doc history)
134+
(filterv (comp (partial = "ilshat@sultanov.team") :user/email)))
135+
;; => [{:user/email "ilshat@sultanov.team", :xt/id "xtdb-tarantool"}]
136+
)
19137
----
20138

21139
=== Roadmap
22140

23-
- [ ] Add tx-log
141+
- [x] Add tx-log
24142
- [ ] Add kv-store
25143
- [ ] Add document-store
144+
- [ ] Add logging
145+
- [ ] Improve tests
146+
- [ ] Add automatic tarantool configuration (in-memory / vinyl)
147+
- [ ] Add an example of using a tarantool cartridge
148+
- [ ] Add an example of using a tarantool kubernetes operator (single node / cluster / with sharding)
149+
- [ ] Add rockspec and publish tarantool configuration to https://luarocks.org[luarocks]?
150+
151+
=== Workflow
152+
153+
==== Development
154+
155+
[source,bash]
156+
----
157+
# run tarantool
158+
$ bb up
159+
160+
# stop tarantool
161+
$ bb down
162+
163+
# run repl
164+
$ bb repl
165+
166+
# check for outdated dependencies
167+
$ bb outdated
168+
169+
# upgrade outdated dependencies
170+
$ bb outdated:upgrade
171+
----
172+
173+
==== Testing
174+
175+
[source,bash]
176+
----
177+
# run linters
178+
$ bb lint
179+
180+
# run linters and fix issues
181+
$ bb lint:fix
182+
183+
# run only unit tests
184+
$ bb test:unit
185+
186+
# run only integration tests (requires a running tarantool)
187+
$ bb test:integration
188+
189+
# run all tests
190+
$ bb test
191+
----
192+
193+
==== Build & deploy
194+
195+
[source,bash]
196+
----
197+
# build jar
198+
$ bb jar
199+
200+
# install locally
201+
$ bb install
202+
203+
# deploy to clojars
204+
$ bb deploy
205+
----
206+
207+
==== Other tasks
208+
209+
[source,bash]
210+
----
211+
$ bb tasks
212+
----
26213

27214
=== License
28215

0 commit comments

Comments
 (0)