c***@shh.mpg.de
2017-04-19 23:17:52 UTC
I would like to use the diatomic client api but I am having trouble
installing db/fn.
I get:
[{:type java.lang.RuntimeException
:message "java.lang.Exception: Not supported: class clojure.lang.Delay"
:at [com.cognitect.transit.impl.WriterFactory$2 write
"WriterFactory.java" 150]}
when trying to transact:
(def rj-f (d/function
{:lang "clojure"
:params '[db job-id]
:code
'(let [result (datomic.api/q '[:find ?s
:in $data ?job-id
:where [$data ?e :job/id
?job-id]
[$data ?e :job/status
?s]]
db
job-id)
status (ffirst result)
heartbeat (quot (System/currentTimeMillis) 1000)]
(if-not (#{:finished :aborted :failed} status)
[[:db/add [:job/id job-id] :job/status :started]
[:db/add [:job/id job-id] :job/heartbeat heartbeat]]
(throw (ex-info (format "Job %s: status %s not eligible
for start." job-id status)
{:overseer/error :ineligible}))))}))
(def ^:no-doc reserve-job-tx-list
"Datomic database function to atomically reserve a job (mark as started
and include initial heartbeat)
Either reserves the given job id, or throws."
[{:db/ident :reserve-job
:db/fn rj-f}])
installing db/fn.
I get:
[{:type java.lang.RuntimeException
:message "java.lang.Exception: Not supported: class clojure.lang.Delay"
:at [com.cognitect.transit.impl.WriterFactory$2 write
"WriterFactory.java" 150]}
when trying to transact:
(def rj-f (d/function
{:lang "clojure"
:params '[db job-id]
:code
'(let [result (datomic.api/q '[:find ?s
:in $data ?job-id
:where [$data ?e :job/id
?job-id]
[$data ?e :job/status
?s]]
db
job-id)
status (ffirst result)
heartbeat (quot (System/currentTimeMillis) 1000)]
(if-not (#{:finished :aborted :failed} status)
[[:db/add [:job/id job-id] :job/status :started]
[:db/add [:job/id job-id] :job/heartbeat heartbeat]]
(throw (ex-info (format "Job %s: status %s not eligible
for start." job-id status)
{:overseer/error :ineligible}))))}))
(def ^:no-doc reserve-job-tx-list
"Datomic database function to atomically reserve a job (mark as started
and include initial heartbeat)
Either reserves the given job id, or throws."
[{:db/ident :reserve-job
:db/fn rj-f}])
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.