This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-25
Channels
- # announcements (2)
- # babashka (35)
- # beginners (74)
- # calva (26)
- # cider (14)
- # clojure (74)
- # clojure-dev (27)
- # clojure-europe (9)
- # clojure-italy (2)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (9)
- # clojuredesign-podcast (6)
- # clojurescript (40)
- # data-science (1)
- # datalog (7)
- # events (1)
- # figwheel-main (13)
- # fulcro (11)
- # graalvm (58)
- # helix (4)
- # jobs (4)
- # jobs-discuss (9)
- # kaocha (23)
- # malli (5)
- # meander (112)
- # membrane (7)
- # off-topic (13)
- # pedestal (2)
- # re-frame (4)
- # reitit (1)
- # rewrite-clj (1)
- # rum (2)
- # sci (3)
- # shadow-cljs (79)
- # sql (12)
- # tools-deps (17)
- # vim (15)
- # vrac (11)
- # xtdb (6)
is there a recommended Java API approach or documentation about it? I see there is https://github.com/juxt/crux/issues/360 done, but not sure where to find the docs for it.
for example: a https://crux-doc.s3.eu-west-2.amazonaws.com/crux-javadoc/20.08-1.10.1/crux/api/ICruxIngestAPI.html#submitTx(java.util.List) takes a list of lists, and it comes down to a https://github.com/juxt/crux/blob/88771f6ab32363a2bf5d54aff6a55924b8887d2c/crux-core/src/crux/tx/conform.clj#L9-L12 function that verifies that each doc in that list is a map
however there is also a https://github.com/juxt/crux/blob/b050da6dc412229388869495866aae927dc63f95/crux-core/src/crux/api/alpha/PutOperation.java that conveniently adds keyword("crux.tx/put")
and friends, but it is constructed from the https://github.com/juxt/crux/blob/b050da6dc412229388869495866aae927dc63f95/crux-core/src/crux/api/alpha/Document.java and not a map, so they don’t seem to fit the List of Maps expectation of submitTx
but.. then it looks like https://github.com/juxt/crux/blob/2b9eeda227820863caca9a74a93a7f6732f8d13d/crux-test/test/crux/java_api_test.clj#L44 in tests.. ))
I was pointed to this page when I asked for Java examples: https://github.com/juxt/crux/discussions/1012
The idea here is, that you write plain crux statement as a string: e.g.:
String put = "[:crux.tx/put\n" +
"{:crux.db/id :someId\n" +
":foo \"foo\"\n" +
":bar \"bar\"\n" +
"}]";
And read it through Clojure read api:
Object datafied = Clojure.read(put);
The output of this function can be passed down the Crux API:
node.submitTx((List<List<?>>) datafied)
it’s not exactly that simple with real Java nested object ) also hard to compose Java and Clojure functions. I added something to yang that was useful: https://github.com/tolitius/yang#java to get this done, but I have not used ICruxIngestAPI.submitTx
I just handrolled some of these:
static IFn submitTx() {
require.invoke(Clojure.read("crux.api"));
return Clojure.var("crux.api", "submit-tx");
}
static IPersistentVector toTx(Object event) {
return (PersistentVector) vector.invoke(TX_PUT, event);
}
Hi @U0541KMAZ sorry for the late response. Unfortunately we should have removed / deprecated the /api/alpha
code already as it is not going to be supported. We will be working on another Java-friendly implementation soon however