Fork me on GitHub
#datomic
<
2017-08-22
>
augustl06:08:25

I wish there was a "transactor library" as well as a peer library, as an alternative to shipping code as strings to the transactor

augustl06:08:44

a library where you spawn the transactor server yourself, and there's hooks for processing transactions and registering transaction functions

augustl06:08:15

so you can redeploy your transactor service, rather than shipping strings and running code in a "foreign" place

augustl06:08:24

would also allow for transactor functions to be written in any JVM language

dm306:08:13

@hmaurer - it’s a bit more involved than that 🙂 I know I could do it on the peer, hence my 2nd solution. I’d really like to avoid it though.

favila11:08:09

@augustl cognitect's advice is to add a jar to the transactor classpath with your code. Then the tx fn impl just calls something from that jar

favila11:08:32

The problem with these approaches is that it doesn't version code in the same timeline as data

augustl11:08:00

ah, didn't know that was possible, but that makes sense

augustl11:08:27

are there any practical problems with not having the transaction functions in the database, versioning/history/timeline wise?

raymcdermott17:08:35

hello folks - simple question that is annoyingly hard to google…

raymcdermott17:08:51

I have a uri type

raymcdermott17:08:11

I try to add “https:/some-url,.com”

raymcdermott17:08:19

but it blows up

raymcdermott17:08:44

what is the magic to convert this string into a literal URi?

raymcdermott17:08:33

:cause :db.error/wrong-type-for-attribute Value https://some-url.com is not a valid :uri for attribute :person/photo

hmaurer17:08:49

@raymcdermott (java.net.URI. "")

raymcdermott17:08:36

ok, yes … so no literal?

hmaurer17:08:53

what do you mean?

hmaurer17:08:03

Datomic’s URIs are java.net.URI instances

raymcdermott17:08:34

I can move on 🙂

hmaurer17:08:05

@raymcdermott ah; #uuid is a reader macro which creates an instance of java.util.UUID

hmaurer17:08:15

=> (type #uuid "6c84fb90-12c4-11e1-840d-7b25c5ee775a")
#<[email protected] java.util.UUID>

hmaurer17:08:23

there does not appear to be a similar reader macro for URIs

raymcdermott17:08:24

yes, indeed. Thanks

raymcdermott17:08:40

bit of a shame but there we are 🙂

devth17:08:52

you can make one 🙂

raymcdermott17:08:16

it means you cannot put it into an edn file

raymcdermott17:08:27

which is the main drawback

kvlt17:08:29

Hey all, I’m running into an odd problem. On my docker container I’m unable to pull datomic-pro yet locally I am. I have set teh following:

:repositories [["" {:url ""
                                    :username [:env/datomic_username]
                                    :password [:env/datomic_password]}]]
and have those environment variables set in the docker container

hmaurer17:08:37

@raymcdermott ah if it’s in an EDN file it’s easy

kvlt17:08:38

I know I’m doing something stupid, I just can’t figure out what

devth17:08:55

i do the same. works for me. double check your env vars?

devth17:08:13

except i use this format:

:repositories {"" {:url ""
                                   :username [:gpg :env/datomic_repo_user]
                                   :password [:gpg :env/datomic_repo_pass]}

kvlt17:08:38

I’ll try that format

kvlt17:08:50

Are you doing this on a docker container?

devth17:08:14

a docker container running in CI builds an uberjar

devth17:08:26

so at runtime i don't need datomic credentials to download the jar

kvlt17:08:33

Hmmm fair enough

kvlt17:08:50

I’ll doubel check the creds again

devth17:08:13

exec into the docker container and echo the env vars for a sanity check 🙂

kvlt17:08:46

I have done, they match

kvlt17:08:08

it downloads using wget

kvlt17:08:11

But not through lein

devth17:08:23

ah, strange

kvlt17:08:42

Could not transfer artifact com.datomic:datomic-pro:pom:0.9.5407 from/to (): Not authorized , ReasonPhrase:Unauthorized.

devth17:08:45

different profiles activated?

kvlt17:08:49

Definitely seems to be user/pass related

devth17:08:09

newlines at the end of the env vars?

kvlt17:08:42

I’m going to try using gpg, mind if I ask how you got those creds onto your CI?

kvlt17:08:45

Did you build them there?

devth17:08:59

i didn't - i use gpg for local creds and env for CI

kvlt17:08:43

gpg --default-recipient-self -e ~/.lein/credentials.clj > ~/.lein/credentials.clj.gpg So you did this <- and just copied that to the ci?

kvlt17:08:00

Surely that wouldn’t as the private key isn’t known to the ci

devth17:08:54

nope, not using gpg in CI

kvlt18:08:10

Sorry I missread, my bad!

hmaurer17:08:43

you can define custom tags when parsing the edn

hmaurer17:08:51

with the :readers options iirc

raymcdermott17:08:57

@hmaurer I’m gonna have to think about that

kvlt17:08:03

This all works fine outside of the container

hmaurer17:08:07

(clojure.edn/read-string input {:readers {'uri #(new java.net.URI %)}}

raymcdermott17:08:07

@hmaurer I’ll give it a shot, though TBH I find it irksome that the supported data types don’t have reader literals

hmaurer17:08:23

@raymcdermott these are Datomic’s supported data types. I am not sure why uuid has a reader macro in clojure and URI does not, but you can’t have a reader literal for every type anyway

hmaurer17:08:43

maybe someone else can elighten us on this

alexmiller17:08:44

b/c java.net.URI is a disaster

val_waeselynck18:08:18

Don't be so harsh, it's not that big an issue to have to do a network call for each equality check. Oh wait, it actually is!

donaldball18:08:30

Errrr I thought that particularly design affliction affected java.net.URL, not java.net.URI

hmaurer19:08:54

why is it a disaster? (I am not familiar with java)

val_waeselynck19:08:14

@U04V4HWQ4 oh yeah my mistake. Apologies to java.net.URI 🙂

raymcdermott19:08:39

what’s the emoji for fingers tapping on the bar 😉

alexmiller19:08:30

oh yeah, I was thinking of URL (although URI is no picnic either)

raymcdermott19:08:23

it is a supported type though in Datomic and one of the few ‘complex’ types

raymcdermott19:08:12

and now it seems like it’s being deprecated, at least in this room

donaldball20:08:22

java.net.URI is a data structure dressed up as a class without providing any of the ostensible benefits of a class

raymcdermott20:08:37

describes so many SDK classes…

raymcdermott20:08:09

the main thing is it saves me writing a regex

raymcdermott20:08:50

the constructors pack a decent amount of value

raymcdermott20:08:09

Aside from some minor deviations noted below, an instance of this class represents a URI reference as defined by RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax, amended by RFC 2732: Format for Literal IPv6 Addresses in URLs. The Literal IPv6 address format also supports scope_ids. The syntax and usage of scope_ids is described here. This class provides constructors for creating URI instances from their components or by parsing their string forms, methods for accessing the various components of an instance, and methods for normalizing, resolving, and relativizing URI instances. Instances of this class are immutable.

raymcdermott20:08:05

still waiting for the knife in the heart of URI

alexmiller20:08:50

you can always validate with URI, then store in a string (or a map in pieces)

raymcdermott20:08:43

datomic has a uri type

raymcdermott20:08:57

that’s what we’re discussing, no?

raymcdermott20:08:53

my goal is to understand why it’s not good practise to use it

alexmiller20:08:40

sorry, I walked into this in the middle and carefully avoided all important context

alexmiller20:08:11

I thought the question was why clojure didn’t have a #uri literal. if you’re using Datomic, then go for it.

raymcdermott20:08:37

the original point was that there is no easy way to supply uri literals in an edn file

raymcdermott20:08:05

and then we moved on to user supplied readers which is like, yikes

alexmiller20:08:32

does datomic have a #uri reader? I don’t remember.

raymcdermott20:08:32

and then a storm came down on URI 😉

alexmiller20:08:52

yeah, my comments were really about URL, so I’ve managed to create maximal confusion

raymcdermott20:08:10

if I say #uri “https://some-valid-uri” it barfs

raymcdermott20:08:30

LOL, awesome work 🙂

alexmiller20:08:17

if you want to represent uris which will end up in Datomic in edn, then I think creating your own reader literal for them is a reasonably sane thing to do (but I would call them #ray/uri or something namespaced so you don’t collide when some future Clojure version includes them in core)

raymcdermott20:08:00

sure, I’m just a lazy whiner

raymcdermott20:08:51

so many people are writing that code

raymcdermott20:08:45

but OK, good to know that there is nothing intrinsically negative in the use of said URI

alexmiller20:08:26

if only it was possible to package useful code in a way that more than one person could use it

raymcdermott20:08:24

:thinking_face:

robert-stuttaford18:08:50

i wouldn’t use the uri datatype @raymcdermott

robert-stuttaford18:08:20

not sure what using it gets you other than pain 🙂

raymcdermott18:08:39

so uri is not useful in Datomic? Just use strings?

raymcdermott18:08:57

maybe somebody better tell the Datomic team 😉

raymcdermott18:08:08

but I will explain why types are sometimes useful if you insist @robert-stuttaford 😉

raymcdermott18:08:18

goes against the grain though

kvlt19:08:16

Anyone have a link to the docs for updating a transactor on aws?

stijn19:08:52

@petr there are several ways to do it, but updating the cloudformation stack through the aws console is probably the easiest http://docs.datomic.com/aws.html#aws-management-console

kvlt19:08:01

@stijn I was thinking more in terms of updating the version/cw metrics. Basically the stuff set in the config files

stijn19:08:00

the version is a parameter in the cloudformation stack

stijn19:08:00

i'm not sure about cw metrics though

kvlt19:08:59

OH sweet

kvlt19:08:03

I didn’t know that

raymcdermott21:08:49

@hmaurer I tried to add my own reader as suggested and now the datomic reader is missing

raymcdermott21:08:25

CompilerException java.lang.RuntimeException: No reader function for tag db/id, compiling:(core.clj:141:25)

raymcdermott21:08:56

is there a way to chain them?

hmaurer21:08:21

@raymcdermott how are you reading your edn file?

hmaurer21:08:33

and how were you reading it previously?

raymcdermott21:08:29

(def data-tx (edn/read-string reader-opts (slurp “resources/data.edn”)))

raymcdermott21:08:46

where reader-opts

raymcdermott21:08:47

(def reader-opts {:readers {‘uri #(new java.net.URI %)}})

raymcdermott21:08:24

(def data-tx (read-string (slurp “resources/data.edn”)))

raymcdermott21:08:33

so not using the edn reader

hmaurer21:08:05

I am not too sure how the Datomic library defines the EDN tag literals, so I can’t advise you on how to merge your custom ones. Someone more knowledgeable might be able to answer 🙂

raymcdermott21:08:54

so maybe @robert-stuttaford is right … pure pain … what do you think @alexmiller?

raymcdermott22:08:20

It’s midnight here so I have to go catch my carriage home…. ttyl

alexmiller22:08:00

well, you can either set up an external data_readers.clj in your project (it should be merged with all others found on the classpath) OR you can explicit bind your own around the reader call

alexmiller22:08:36

binding *data-readers* that is

alexmiller22:08:03

(doc *data-readers*) is a good place to start

alexmiller22:08:23

this and all the related things around it is an area ripe for a guide

alexmiller22:08:24

but could use some more exposition and examples

bbloom23:08:49

if i’m using lein - what’s the least painful way to get my code on the classpath in a way that datomic db.fn :requires can find it?

bbloom23:08:40

this is how i’ve unblocked myself:

bbloom23:08:45

(let [cl (.getContextClassLoader (Thread/currentThread))
        dcl (clojure.lang.DynamicClassLoader. cl)]
    (.setContextClassLoader (Thread/currentThread) dcl)
    (add-classpath "file://./src"))

bbloom23:08:47

¯\(ツ)