-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d8ee0e
commit cd70087
Showing
1 changed file
with
192 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
== xtdb-tarantool | ||
image:https://img.shields.io/github/license/sultanov-team/xtdb-tarantool[license,link=license] | ||
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] | ||
image:https://github.com/sultanov-team/xtdb-tarantool/workflows/build/badge.svg[build] | ||
|
||
XTDB module allows you to use Tarantool (in-memory computing platform). | ||
image:https://img.shields.io/clojars/v/team.sultanov/xtdb-tarantool.svg[clojars,link=https://clojars.org/team.sultanov/xtdb-tarantool] | ||
|
||
== XTDB Tarantool | ||
|
||
https://www.xtdb.com[XTDB] module allows you to use https://www.tarantool.io/[Tarantool] (in-memory computing platform). | ||
|
||
**Status: ** Alpha. | ||
The design and prototyping stage. | ||
|
@@ -12,17 +18,198 @@ Add the following dependency in your project: | |
[source,clojure] | ||
---- | ||
;; project.clj or build.boot | ||
[team.sultanov/xtdb-tarantool "RELEASE"] | ||
[team.sultanov/xtdb-tarantool "0.1.56-SNAPSHOT"] | ||
;; deps.edn | ||
team.sultanov/xtdb-tarantool {:mvn/version "RELEASE"} | ||
team.sultanov/xtdb-tarantool {:mvn/version "0.1.56-SNAPSHOT"} | ||
---- | ||
|
||
=== Usage | ||
|
||
*Requirements* | ||
|
||
First you need to configure the Tarantool: | ||
|
||
- link:docker-compose.yaml[Docker compose] | ||
- link:src/main/tarantool/xtdb.lua[Tarantool configuration] | ||
|
||
[source,clojure] | ||
---- | ||
;; src/develop/clojure/xtdb/tarantool/example.clj | ||
(ns xtdb.tarantool.example | ||
(:require | ||
[clojure.tools.namespace.repl :as tools.repl] | ||
[integrant.core :as ig] | ||
[integrant.repl :as ig.repl] | ||
[integrant.repl.state :as ig.repl.state] | ||
[xtdb.api :as xt] | ||
[xtdb.tarantool :as tnt]) | ||
(:import | ||
(java.io | ||
Closeable) | ||
(java.time | ||
Duration))) | ||
(tools.repl/set-refresh-dirs "src/dev/clojure") | ||
(defn config | ||
[] | ||
{::xtdb-tnt {::tnt-client {:xtdb/module 'xtdb.tarantool/->tnt-client | ||
:username "root" | ||
:password "root"} | ||
:xtdb/tx-log {:xtdb/module 'xtdb.tarantool/->tx-log | ||
:tnt-client ::tnt-client | ||
:poll-wait-duration (Duration/ofSeconds 5)} | ||
:xtdb.http-server/server {:read-only? true | ||
:server-label "[xtdb-tarantool] Console Demo"}}}) | ||
(defn prep | ||
[] | ||
(ig.repl/set-prep! config)) | ||
(defn go | ||
[] | ||
(prep) | ||
(ig.repl/go)) | ||
(def halt ig.repl/halt) | ||
(def reset-all ig.repl/reset-all) | ||
(defn system | ||
[] | ||
ig.repl.state/system) | ||
(defmethod ig/init-key ::xtdb-tnt [_ config] | ||
(xt/start-node config)) | ||
(defmethod ig/halt-key! ::xtdb-tnt [_ ^Closeable node] | ||
(tnt/close node)) | ||
(comment | ||
(reset-all) | ||
(halt) | ||
(go) | ||
;; open http://localhost:3000/ | ||
(def node | ||
(::xtdb-tnt (system))) | ||
(xt/submit-tx node [[::xt/put {:xt/id "xtdb-tarantool", :user/email "[email protected]"}]]) | ||
;; => #:xtdb.api{:tx-id 1, :tx-time #inst"2021-12-04T01:27:15.641-00:00"} | ||
(xt/q (xt/db node) '{:find [e] | ||
:where [[e :user/email "[email protected]"]]}) | ||
;; => #{["xtdb-tarantool"]} | ||
(xt/q (xt/db node) | ||
'{:find [(pull ?e [*])] | ||
:where [[?e :xt/id "xtdb-tarantool"]]}) | ||
;; => #{[{:user/email "[email protected]", :xt/id "xtdb-tarantool"}]} | ||
(def history (xt/entity-history (xt/db node) "xtdb-tarantool" :desc {:with-docs? true})) | ||
;; => [#:xtdb.api{:tx-time #inst"2021-12-04T01:31:14.080-00:00", | ||
;; :tx-id 2, | ||
;; :valid-time #inst"2021-12-04T01:31:14.080-00:00", | ||
;; :content-hash #xtdb/id"d0eb040d39fbdaa8699d867bc9fb9aa244b8e154", | ||
;; :doc {:user/email "[email protected]", :xt/id "xtdb-tarantool"}}] | ||
(->> (map ::xt/doc history) | ||
(filterv (comp (partial = "[email protected]") :user/email))) | ||
;; => [{:user/email "[email protected]", :xt/id "xtdb-tarantool"}] | ||
) | ||
---- | ||
|
||
=== Roadmap | ||
|
||
- [ ] Add tx-log | ||
- [x] Add tx-log | ||
- [ ] Add kv-store | ||
- [ ] Add document-store | ||
- [ ] Add logging | ||
- [ ] Improve tests | ||
- [ ] Add automatic tarantool configuration (in-memory / vinyl) | ||
- [ ] Add an example of using a tarantool cartridge | ||
- [ ] Add an example of using a tarantool kubernetes operator (single node / cluster / with sharding) | ||
- [ ] Add rockspec and publish tarantool configuration to https://luarocks.org[luarocks]? | ||
|
||
=== Workflow | ||
|
||
==== Development | ||
|
||
[source,bash] | ||
---- | ||
# run tarantool | ||
$ bb up | ||
# stop tarantool | ||
$ bb down | ||
# run repl | ||
$ bb repl | ||
# check for outdated dependencies | ||
$ bb outdated | ||
# upgrade outdated dependencies | ||
$ bb outdated:upgrade | ||
---- | ||
|
||
==== Testing | ||
|
||
[source,bash] | ||
---- | ||
# run linters | ||
$ bb lint | ||
# run linters and fix issues | ||
$ bb lint:fix | ||
# run only unit tests | ||
$ bb test:unit | ||
# run only integration tests (requires a running tarantool) | ||
$ bb test:integration | ||
# run all tests | ||
$ bb test | ||
---- | ||
|
||
==== Build & deploy | ||
|
||
[source,bash] | ||
---- | ||
# build jar | ||
$ bb jar | ||
# install locally | ||
$ bb install | ||
# deploy to clojars | ||
$ bb deploy | ||
---- | ||
|
||
==== Other tasks | ||
|
||
[source,bash] | ||
---- | ||
$ bb tasks | ||
---- | ||
|
||
=== License | ||
|
||
|