Fork me on GitHub
#clojure
<
2016-05-12
>
joelkuiper11:05:55

has anyone ever used the quartz scheduler with System or Component?

joelkuiper11:05:15

I’d like to pass a database connection into the scheduled jobs, but I don’t think the context is a good way of doing that

joelkuiper11:05:53

I guess I’ll use defrecord instead of defjob and pass in the database there, also does not seem very idiomatic though

josh.freckleton12:05:55

general architecting question: my users can schedule a recurring service at a certain frequency (daily, weekly, monthly) kind of like google calendars recurring events. Note, I'm using MongoDB, so relational stuff is a little more difficult, but I could change the db if needed. 1.) When a user makes a new recurring service, should I populate a global "queue" (in a db) with the times of that service a few years out? (then if they cancel/modify their service, I walk through all the pre-made events to change them) 2.) Or should I do a cron job every morning that walks over every user and determines if they should have a scheduled service today and adds today's service to a sort of "queue"? 3.) Something else?

Prakash13:05:13

@josh.freckleton: I like the 1st solution, with 2nd, cancelling out or modifying services will be difficult something like “this event everyday but not tomorrow

Prakash13:05:35

in general, adding some info to service of a particular day will be difficult

Prakash13:05:32

or probably , u can have a mix of 1 and 2. global queue for near future. and running cron job less frequently than a day.

sveri13:05:56

@josh.freckleton: If 1. is possible depends mainly on the library for synchronization. IIRC there are scheduling libs that will have a delay on recurring events over the time. Also, if you go for that solution, you will have to rebuild the "services" on every restart of your application from scratch, which could take its time, depending on your solution

josh.freckleton13:05:15

@sveri "rebuild services every restart" only if the queue was in memory right? But I would probably have the "queue" in a db, or am I mistaken?

sveri13:05:08

@josh.freckleton: I guess you will need a mix, longterm events in a persisten storage and the "short" term services in memory

josh.freckleton13:05:36

@pcbalodi: mix is probably the way to go. Maybe cron job determines this weeks schedule, and then certain functions can modify the "queue" @sveri: the client that needs to look at the queue of services will probably just poll the "queue" and the short term services will be in his browser/app's memory

arrdem18:05:18

Does anyone have a good embedded datastore they'd suggest? I'm working on a game rule system of sorts, and I need to store records describing the various entities in the game. I've been using core.logic's pldb to structure records as a bunch of fact tuples sharing an ID value and I've found this to be... difficult to reason about. Suggestions would be appreciated.

arrdem18:05:20

Seems like the state of the art is either an embedded SQL like H2 or just using EDN.

bja18:05:09

datascript has been nice to me

iuriikondratiuk20:05:44

does anyone know if there already exist an implementation of GraphQL for Closure ?

mateus.henrique.brum20:05:49

=>(def ts [{:t 0} {:t 1}]) =>(for [x ts] (:t x)) (0 1)

mateus.henrique.brum20:05:17

there is a better solution to extract values from a vector of hash ??

jswart20:05:31

(map :t ts)

juhoteperi20:05:38

@seancorfield: Have you run Java.jdbc tests on Postgres lately? I'm seeing lots of failures

hiredman20:05:05

failures running jdbc's tests against postgres?

juhoteperi20:05:36

Yes. I'm trying to debug a problem with insert! not working without transaction, but while running java.jdbc tests pretty much everything fails so I'm not sure if there is something wrong with my setup.

juhoteperi21:05:40

I tested a few older releases and tests don't work on Postgres with those either

juhoteperi21:05:51

Anyway, I'm seeing a potential problem in this commit, :transaction? used to default to true if the option was not given, now there is no default value: https://github.com/clojure/java.jdbc/commit/310781429225b614cab01256f3adce54917644aa#diff-3a9a3475f16407a50d922fad53957b01L945

juhoteperi21:05:16

In that commit transaction? default value is set in insert! but that code is removed in latter comit

hiredman21:05:11

I am seeing errors locally as well, looks like the tests are trying to create the fruit table over and over, but it already exists

hiredman21:05:03

the fixture that is supposed to drop the table in between tests is swallowing exceptions

hiredman21:05:45

ah, because all the deletes are now happening in a transaction, when one of the deletes fails, the rest don't happen, and of course you would only see this in postgres because I doubt any of the other dbs tested against have transactional ddl

hiredman21:05:46

if you replace clean-up in the tests with that, the test should work again

hiredman21:05:35

boy do I hate getNextException

juhoteperi21:05:11

Yeah, thanks. Now I'm seeing other problems because in postgres insert returns the rows instead of just ids.

hiredman21:05:03

oh, whoops, I commented a bunch of tests out while I was poking at it

hiredman21:05:25

yeah, looks like postgres is broken 😞

juhoteperi22:05:45

Huh, when using certain insert! arity postgres returns just ids 😕

akjetma22:05:28

Is there a commonly used convention for naming atoms? I generally write my code in a way that passes around the dereferenced atom’s value rather than the atom but it’s not immediately clear when you’re dealing with the atom or its value

val_waeselynck22:05:47

@akjetma: never found such convention either, my way to do it is prefix it with a_

hiredman22:05:17

a- at least use a hyphen

val_waeselynck22:05:04

@hiredman: what's wrong with underscores? I like the visual contrast they provide

akjetma22:05:05

i have experimented with a single trailing earmuff, appending -state to the atom, appending val to its value. It all feels dirty

hiredman22:05:09

the difference between the atom and the value is the value is a value, and the atom is a reference or identity, so you can use that to make up a name

hiredman22:05:27

user-identity vs user or whatever

hiredman22:05:45

clojure names typically eschew underscores for hyphens, and many clojure programmers have a preference for hyphens, to the point that at my last job there was a big push to run everything (from json, or a database) through a conversion function so the names in the map were more clojure like, which made it easier to bind clojure style names using destructuring

akjetma22:05:45

wait a sec, i think i just realized why it feels especially dirty with the thing i'm working on. i have an atom/value that i want to call db because it is used as a shim for a database. so distinguishing between the value and state of a thing called db is an extra layer of weirdness.

hiredman22:05:25

I didn't particularly care for that, I think it was a waste, but it goes to show how deep the preference runs

akjetma22:05:36

i can see how that could be frustrating or satisfying depending on your outlook, hah

val_waeselynck22:05:14

@hiredman: I like to have the possibility to use both as separators, just as I like the fact that Clojure syntax has both lists and vectors - nice for contrast. But I get that some people may view it as dirty

hiredman22:05:20

there are, in fact, some bugs related to and -, last I checked (which was a few years ago) which cause things to explode if you try and let bind both ab and a-b if I recall correctly

akjetma22:05:06

certainly maybe true with js

akjetma22:05:21

if you export a function, iirc

hiredman22:05:21

I may be miss remembering the exact thing that triggers the bug

seancorfield22:05:32

@juhoteperi: Sorry, I’ve always relies on others testing java.jdbc against Postgres quickly enough to catch failures early… but several regular Postgres testers seemed to have moved on (either from using Postgres or using Clojure, I don’t know) and I no longer get any feedback on it.

seancorfield22:05:10

I’m happy to fix any Postgres-related problems if folks can give me enough pointers — or a patch! — to get things working again.

seancorfield22:05:43

There was talk of having Postgres available on the Clojure CI system so it would get tested there… but in the end that never happened, as far as I know.

seancorfield22:05:30

I guess I could use Docker to have a Postgres environment for testing. I do test against MS SQL Server (using both the MS Type 3 driver and jTDS) with a Windows XP VM running on my Mac! simple_smile

seancorfield22:05:10

Oh, looks like you beat me to it with the JIRA tickets… Thank you!

seancorfield22:05:45

I created JDBC-129 to get a PostgreSQL test environment up and running. Then it can be a standard part of my testing in future. And you’re right about the transactional DDL — that’s just a silly bug to attempt to rely on that since it is not transactional in many (most?) DBs.

juhoteperi22:05:02

@seancorfield: Great! I have to go to sleep now but will continue in the morning.

juhoteperi22:05:07

One solution to running tests would be to use CircleCI, they have Postgres and MySQL available 🙂

bronsa23:05:31

@hiredman:

((let [a_b 1 a-b 2] (fn [] [a-b a_b])))
[2 2]

bronsa23:05:45

only happens if you close over because of static field (by munged name) vs local variable table (by idx)