What is the best way to call clojure workflows on Heroku?

I am currently running a task through the scheduler. It works a few minutes. I have no reason to think that it is closed for work too long, but I wonder if it should be a workflow.

How do I start a clojure process in a workflow? Is it as simple as setting up a ProcFile and scheduler commands?

My ProcFile:

web: lane with production profile trampoline run -m webhook.server

My application: - Once an hour, retrieve data into the Heroku database through a scheduled web service call to another server. - On demand, the call-based web service serves JSON data for another process elsewhere on the Internet.

+4
source share
1 answer

It seems that you can create a Heroku "Worker" speaker that starts a plain old Java thread. For example, you might have a Clojure application with the -main function, which uses concurrency, i.e.

 (defn -main [&args] (doseq [res (map deref [(future "task 1") (future "task 2") (future "task 3"])] (save-results res))) 

Where save-results is an imaginary function that somewhere saves the results of your employee, sends an email no matter.

Please note that this is probably the best way to do this, i.e. Agents or one of the Clojure Schedule libraries listed on the Clojure Toolbar (i.e. quartzite). My example is a very simple (naive?) Example that proves concurrency in the working dynamics of Heroku.

See here for further discussion: https://groups.google.com/forum/#!topic/clojure/xQs6MqD3680

In addition, I found several blog posts / articles about running multiple threads on the same Heroku dinar. This limits you to something like 255 streams per dyno.

Update I created a proof of concept for the above:

https://github.com/noahlz/worker-sample

+1
source

Source: https://habr.com/ru/post/1481241/


All Articles