Fork me on GitHub
#datomic
<
2019-12-23
>
onetom05:12:43

im a bit confused about the relation of ~/.m2/repository/com/datomic/client-cloud/0.8.81/client-cloud-0.8.81.jar to the /Users/onetom/.m2/repository/com/datomic/client-api/0.8.38/client-api-0.8.38.jar library.

onetom05:12:46

the later seems to provide the datomic.client.api namespace, but it's not mentioned in the cloud docs: https://docs.datomic.com/cloud/client/client-api.html

onetom05:12:43

the on-prem docs only mentions the com.datomic/client-pro lib. both of them seem to provide the datomic.client.api namespace, but if i look into the client-cloud jar, it only contains code for a datomic.client.impl.cloud ns.

onetom05:12:07

there is also no documentation for the :cloud value for the :server-type key in the client api config data structure, only for the :ion type: https://docs.datomic.com/cloud/ions/ions-reference.html#server-type-ion

onetom05:12:21

which library should i include into my project? i would like to develop locally offline too, so im starting a peer-server and i would connect to it via the com.datomic/client-pro lib and a {:server-type :peer-server} config, but if i would want to connect to the cloud version too with the :ion server type, what should i do?

onetom06:12:31

ah, i see the same transitive dependency is there in both libraries:

<dependency>
  <groupId>com.datomic</groupId>
  <artifactId>client</artifactId>
  <version>0.8.87</version>
</dependency>
and the datomic.client.api/client function understands all server-types:
(case (:server-type arg-map)
        :ion
        (client (assoc arg-map :server-type (impl/ion-server-type)))
        
        (:cloud :peer-server)
        (impl/dynacall 'com.datomic/client
                       'datomic.client.api.sync/client
                       arg-map)

        (:peer-client)
        (impl/dynacall '(or com.datomic/datomic-pro com.datomic/datomic-free)
                       'datomic.peer-client/create-client
                       arg-map)

        :local
        (impl/dynacall 'com.datomic/client-impl-local
                       'datomic.client.impl.local/create-client
                       arg-map)
        (throw (impl/incorrect ":server-type must be one of :cloud, :local, :peer-client, or :peer-server")))

onetom07:12:45

or not?

Execution error (FileNotFoundException) at datomic.client.api.impl/dynaload (impl.clj:15).
Could not locate datomic/client/impl/pro__init.class, datomic/client/impl/pro.clj or datomic/client/impl/pro.cljc on classpath.

onetom07:12:16

also, the https://docs.datomic.com/on-prem/getting-started/connect-to-a-database.html page doesn't mention the need for the :validate-hostnames false option, while the https://docs.datomic.com/on-prem/peer-server.html#connecting page does. I was getting a No name matching localhost found error otherwise, or when I changed localhost to 127.0.0.1, it was throwing a No subject alternative names present error.

marshall14:12:55

@onetom The on-prem client and cloud client libraries are different dependencies but have some shared internals (As you determined) I’ll fix that missing validate-hostnames part in the docs, thanks for finding that You’ll need to use a different dependency in your project to connect to cloud than to connect to peer-server; I don’t think you can have them both active at the same time (CP and name conflicts); but you could use an alias in your deps and have the different config maps available in your code depending on which you’re connecting to

👍 4
dvingo23:12:22

I have some queries that all retrieve a common set of properties from a few entities, but each query adds a few different fields. I'm wondering if it is a good idea to add helpers to write parts of the query, something like this:

(def my-query
  {:find
          (conj (select-fields-symbols) '?property)
   :keys  (conj (select-fields-keys) 'property)
   :where (conj (select-fields-query '?project)
                '[?project :project/d ?d]
                '[?project :my-other/property ?property])}
  ;; =>
  '{:find  [?a ?b ?c ?d ?property]
    :keys  [a b c d property]
    :where [[?project :project/a ?a]
            [?project :project/b ?b]
            [?project :project/c ?d]
            [?project :project/d ?d]
            [?project :my-other/property ?property]]}
Where we always want the fields (a, b, c, d), but depending on the situation also want to add a few additional fields, or join to other entities. Is there some other way to go about this? Should I just duplicate the fields and not overthink things? One other strategy I'm considering is to make multiple queries, the first one to get a set of common properties and then another to add on the additional fields I want.

dvingo23:12:25

I think I answered my own question.... Use the pull API..

👍 4