There is no distinct “memory space” so your ion should be able to access any state that is correctly instantiated. Http-direct and lambda proxy’s both call ions. As long as the state is present on all cluster nodes you should be able to access it. however mount can add it’s own challenges due to piggy backing on ns loading. I can usually get by without a framework and instead just wrap my state in a delay and initializing it on the first access (what delays are for).
I’m sure I’m missing something, but does anyone know what might be causing this? (It’s fine locally, but it fails on a EC2 instance)
Someone already asked this, so sharing it here since it might be helpful to others: https://ask.datomic.com/index.php/546/could-not-find-artifact-com-datomic-ion-jar-0-9-48-in-central
I added this EC2 to the same VPC as Datomic Cloud - I’m not sure this is the way to go, I’m trying to figure things out.
I added an SSH inbound rule, but that’s it, I didn’t mess with any other configuration.
(Clojure CLI version 1.10.3.855)
I create entities like so and put some values in those entities. So far there are no errors:
(d/transact conn [{:db/ident :carecoach/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/unique :db.unique/identity
:db/doc "name"}
{:db/ident :carecoach/number
:db/valueType :db.type/long
:db/cardinality :db.cardinality/many
:db/unique :db.unique/identity
:db/doc "number"}
])
(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 20}])
(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 10}])
(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 30}])
(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 20}])
(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 40}])
(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 50}])
But when I try to do a pull, I get the following error:
(defn get-sum [name-string]
(d/pull db '[*] [:carecoach/name name-string])
#_(d/q '[:find ?number
:in $ ?name-string
:where
[?e :carecoach/name ?name-string]
[?e :carecoach/number ?number]
]
db name-string)
)
(get-sum "Deepak")
:db.error/not-an-entity Unable to resolve entity: :carecoach/name
{:entity :carecoach/name, :db/error :db.error/not-an-entity}
error.clj: 57 datomic.error/arg
error.clj: 52 datomic.error/arg
db.clj: 589 datomic.db/require-id
db.clj: -1 datomic.db/require-id
db.clj: 689 datomic.db/require-attrid
db.clj: 686 datomic.db/require-attrid
db.clj: 534 datomic.db/resolve-lookup-ref
db.clj: 526 datomic.db/resolve-lookup-ref
db.clj: 568 datomic.db/extended-resolve-id
db.clj: 564 datomic.db/extended-resolve-id
db.clj: 579 datomic.db/resolve-id
db.clj: 572 datomic.db/resolve-id
How to fix this?db
is from before your transactions
again: you should use the return value of transact
, and you should pass db
in to querying functions as an argument
db
is not a “database handle” like in a normal relational db. You can’t def it once. It’s an immutable value.
transactions change that value and return a new db
you can even use d/with
to produce a new db value without committing it to storage.
https://docs.datomic.com/on-prem/best-practices.html#consistent-db-value-for-unit-of-work
what’s the fastest way to fix this? I’m in a hurry
As favila said, just change get-sum
to take db as an argument. Pass in the the db-after
you get from eg. derefing the return value of the last d/transact