[racket] About DB and events

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Fri Feb 24 17:08:21 EST 2012

I don't think it's possible to do this strictly on the Racket side. Your 
best bet is to see if you can write a PostgreSQL procedure that 
blocks/sleeps until rows are available (or until it hits some timeout) 
and then returns them. PostgreSQL has pg_sleep, LISTEN, NOTIFY, and 
LOCK---some combination of those might be able to express what you want. 
I suggest asking on the PostgreSQL mailing list about that part. On the 
Racket side you just run the query that executes the wait-for-results 
procedure.

Ryan

On 02/24/2012 06:43 AM, Eduardo Bellani wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello list.
>
> I am building a deamon here that pings a postgres database to send
> some messages. A bit like the following code:
>
> (let check-loop
>      ([unsent-messages (get-unsent-messages)]) ;; get messages from DB
>    (for-each (? (message) (do-it! message)) unsent-messages)
>    (sleep *interval*)
>    (check-loop (get-unsent-messages)))
>
> I'm thinking this would be a great task for an event, but I'm having
> some trouble transforming a DB call into an event. Is it possible?
> Feasible? Anyone can think of alternatives? That looping and sleeping
> does not sound like a nice way to code this.
>
>
> Thanks.
> - --
> Eduardo Bellani
>
> fear is an alarm, not a compass.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
>
> iEYEARECAAYFAk9Hk/cACgkQSbLl0kCTjGn4HwCfTfYx7O2Svgs1fU/iozNaH1If
> tp8An2BcNHjnkvXP5FlC5N/4MTzp1Jdr
> =LY9m
> -----END PGP SIGNATURE-----
> ____________________
>    Racket Users list:
>    http://lists.racket-lang.org/users

Posted on the users mailing list.