New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Datomic Client #505
Changes from all commits
2a98382
f319217
f0ac9d2
f9987bc
6aa6c6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
(ns client-test | ||
(:require [datomic.client.api :as d])) | ||
|
||
(System/setProperty | ||
"java.home" | ||
(System/getenv "GRAALVM_HOME")) | ||
|
||
(def client | ||
(d/client | ||
{:server-type :peer-server | ||
:endpoint "localhost:8080" | ||
:secret "bar" | ||
:access-key "foo" | ||
:validate-hostnames false})) | ||
|
||
(def conn | ||
(d/connect client {:db-name "yellowdig"})) | ||
|
||
(def db | ||
(d/db conn)) | ||
|
||
|
||
(println "- transact \n") | ||
(let [data [{:db/id "temp-foo" :test/name :foo}] | ||
tx-res (d/transact conn {:tx-data data})] | ||
(println (:tempids tx-res)) | ||
(d/pull | ||
(:db-after tx-res) | ||
{:eid (get (:tempids tx-res) "temp-foo") | ||
:selector '[*]})) | ||
(println "\n") | ||
|
||
(println "- query \n") | ||
(println | ||
(ffirst | ||
(d/q | ||
'[:find (pull ?e [:user/username :user/firstname]) | ||
:where [?e :user/username "bingo"]] | ||
db))) | ||
(println "\n") | ||
|
||
|
||
(println "- tx-range \n") | ||
(println | ||
(doseq [tx | ||
(d/tx-range | ||
conn | ||
{:limit 10 | ||
:start nil | ||
:end nil})] | ||
(println (:id tx)))) | ||
(println "\n") | ||
|
||
(println "- index range \n") | ||
(println | ||
(take 10 | ||
(d/index-range | ||
(d/db conn) | ||
{:attrid :network/name}))) | ||
(println "\n") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
(ns babashka.impl.datomic-client | ||
(:require [datomic.client.api :as d] | ||
;; these libs and others are dynamically | ||
;; required by the client, depending on use | ||
[datomic.client.api.sync] | ||
[datomic.client.impl.pro])) | ||
|
||
(def client-vars | ||
'#{administer-system | ||
as-of | ||
client | ||
connect | ||
create-database | ||
datoms | ||
db | ||
db-stats | ||
delete-database | ||
history | ||
index-pull | ||
index-range | ||
list-databases | ||
pull | ||
q | ||
qseq | ||
since | ||
sync | ||
transact | ||
tx-range | ||
with | ||
with-db}) | ||
|
||
(def client-namespace | ||
(->> client-vars | ||
(map (fn [v] [v (var-get (ns-resolve 'datomic.client.api v))])) | ||
(into {}))) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ | |
:license {:name "Eclipse Public License 1.0" | ||
:url "http://opensource.org/licenses/eclipse-1.0.php"} | ||
:source-paths ["src" "sci/src" "babashka.curl/src" "babashka.pods/src" | ||
"babashka.nrepl/src"] | ||
"babashka.nrepl/src" | ||
"feature-datomic-client"] | ||
;; for debugging Reflector.java code: | ||
;; :java-source-paths ["sci/reflector/src-java"] | ||
:java-source-paths ["src-java"] | ||
|
@@ -21,7 +22,8 @@ | |
[cheshire "5.10.0"] | ||
[fipp "0.6.22"] | ||
[nrepl/bencode "1.1.0"] | ||
[borkdude/sci.impl.reflector "0.0.1-java11"]] | ||
[borkdude/sci.impl.reflector "0.0.1-java11"] | ||
[com.datomic/client-pro "0.9.57"]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This dependency needs to be hidden behind a profile like |
||
:profiles {:feature/xml {:source-paths ["feature-xml"] | ||
:dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]} | ||
:feature/yaml {:source-paths ["feature-yaml"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We manage resources dynamically in |
||
"resources": [ | ||
{ | ||
"pattern": ".*\\.pem$" | ||
}, | ||
{ | ||
"pattern": ".*\\.json$" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,17 @@ | |
;; java.net.URL, see below | ||
java.net.URLEncoder | ||
java.net.URLDecoder | ||
;; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these classes only need to be brought into the reflection config when the feature flag is enabled. |
||
java.nio.HeapByteBuffer | ||
~(symbol "[Ljava.nio.HeapByteBuffer;") | ||
org.msgpack.template.builder.TemplateBuilderChain | ||
org.msgpack.template.builder.FieldEntry | ||
org.msgpack.template.builder.JavassistTemplateBuilder | ||
org.msgpack.template.ListTemplate | ||
org.msgpack.template.SetTemplate | ||
org.msgpack.template.CollectionTemplate | ||
org.msgpack.template.MapTemplate | ||
;; | ||
~@(when features/java-nio? | ||
'[java.nio.file.OpenOption | ||
java.nio.file.CopyOption | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script probably needs to be implemented as a proper test. See the postgres tests how to execute a test based on a feature flag.