Hi Erik,

It hadn't even crossed my mind that I could write a separate app which is
trigged by cron. I will consider that! I have searched for different
schedulers and found a few options but cannot locate any in Juxt's github
repositories. I've read about transducers and think that I've got a
superficial understanding of them - but not enough to understand their
application in an async context or how they could act as schedulers (if I
understood you correctly).

Thanks,
Brjánn

On Fri, 26 Oct 2018 at 16:15, Erik Assum <e...@assum.net> wrote:

> Expert answer is always “it depends”.
>
> And long winded answer:
>
> I’d first write a function that can send one “email”:
>
> (defn send-email! [ctx email-data] …) ; context contains whatever outside
> resources you need
>
> Now you have the freedom to work on a list of email-data like this:
>
> (doseq [email emails]
>   (send-email ctx email))
>
> So now you could do something like
>
> (let [emails (read-unsent-emails! [db])]
>      (doseq [email emails]
>        (send-email ctx email)))
>
> put that in a main, create a uberjar and make a cronjob which runs every 5
> minutes.
>
> Or, you could as you suggest do it in a scheduler, I think I’ve used a
> clojure wrapper for quartz previously.
> but I know the people from Juxt has some stuff that might be nice as well.
>
> Or you could use make a transducer, (map (partial send-email ctx), and use
> that on your async channel.
>
> Erik.
>
> On 26 Oct 2018, at 15:05, brj...@gmail.com wrote:
>
> You are quite right. My plan is to save emails that must be sent (not all
> need guaranteed delivery) to a database but queue them right away in a
> worker thread. The DB will then be updated with delivery status. In the
> interest of reducing IO, I would prefer not to have to write and read from
> the DB for all emails but only in case of a crash or mail server down
> something similar. So there needs to be continuous monitoring of the email
> table - which requires some sort of ever running task? Would you suggest a
> go block or using a scheduler (there seem to be quite a few options of
> Clojure schedulers).
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to