Fork me on GitHub
#datomic
<
2016-04-11
>
arthur.boyer01:04:46

Does anyone know if there’s a way that I can wrap a Datomic connection and log all the calls that get made to it? I’m working with some inherited spaghetti code and it’s not unusual for me to have no idea when certain kinds of entities are created or updated. My hope is that I can log the events I care about so I can work out what code is responsible. Ideally I’d get a stack trace at those times.

adamkowalski01:04:17

could you make a core async channel which you use to talk to datomic? so rather then calling something directly you put it into the channel which will then do the actual call. then the channel could do arbitrary things, like maybe log something to a file

arthur.boyer01:04:05

The way this thing is built there are a whole bunch of auto-magic macros that wire up functions and local mutable state into a graph. I have control of the place where the connection comes from, but the other functions are littered across the code base, so it is currently impractical to refactor. As such I don’t think a channel will help. Thanks though.

arthur.boyer03:04:51

It looks like I can probably use the [transaction report queue](http://blog.datomic.com/2013/10/the-transaction-report-queue.html) for my needs.

arthur.boyer03:04:59

@adamkowalski: I found a promising lead that uses core.async here: https://github.com/thegeez/gin/blob/master/src/gin/system/database_datomic.clj#L127 Thanks for the suggestion.

sdegutis17:04:29

Is there a simple way to run a query that matches a given string against one of a few attributes? For example, something like this pseudocode: :where [?user :user/email ?string] :or [?user :user/name ?string]

sdegutis17:04:36

Is this possible?

stuartsierra17:04:00

Query syntax supports or — check the docs for the correct syntax

sdegutis17:04:02

Oh wait, I remember why this was more complicated...

sdegutis17:04:48

It was because I'm using clojure.string/includes? to check for a substring of any of these. Which exploded the query into a bunch of temporary variables which I then check with or, and needed to bind with or-join.

sdegutis17:04:24

That explosion of a query is what I'm trying to avoid. Is that possible?

sdegutis17:04:00

Hmm. I'll experiment with it a bit more. I think I can get it simpler.

zentrope17:04:25

I had to use rules to get that working.

zentrope17:04:08

Or lets you test different values of the same attribute, but if you want to (say) search for a string among a few attributes, the rule stuff was what worked for me.

sdegutis17:04:23

@zentrope: Thanks, that sounds promising, will look further into rules.

sdegutis17:04:31

@zentrope: Ahh, I see why that works. Per the docs: "Rules with multiple definitions will evaluate them as different logical paths to the same conclusion (i.e. logical OR)."

sdegutis17:04:37

Beautiful, sounds like exactly what I need.

zane20:04:04

Anyone have any experience with Adi? https://github.com/zcaudate/adi

dominicm21:04:57

@zane: @zcaudate hangs out mostly on his gitter simple_smile https://gitter.im/zcaudate/adi answers loads of questions there

zane21:04:56

@dominicm: Thanks for the heads up! I don't have a specific question. I was just wondering what others' experiences with it have been like.

dominicm21:04:15

@zane: Positive. I really like it.

dominicm21:04:40

He has a lot of great ideas about clojure in general, and his libs reflect that

zane21:04:46

Seems like I have a lot of reading to do.

dominicm21:04:10

Check out hara.event, it's a personal favourite