Re: Custom timer module
Mon Jan 20 11:13:29 CET 2020
Hi, thank you, mnesia could actually be a good fit. I would have to ensure that the schema is created only once (so not being part of the docker container initialization) but that would be better than using tab2file after every write !
I currently have a simple implementation that works well. The only problèm (really not a problem per se) is that it is just a narrow subset of the timer module. It is based on an ETS ordered_set used as a data structure with a peek function that either returns a timed-out entry or a delay to the next entry timeout ; and a gen_server that just handles `timeout` information and run the the next task and/or returns a timeout according to the delay.
As for cron-like application I found that they do not fit well because we sometimes have to pop entries from the table and run them regardless of actual scheduled time.
Le Dimanche, Janvier 19, 2020 15:17 CET, Serge Aleynikov <serge@REDACTED> a écrit:
There's a project https://github.com/erlware/erlcron that implements jobs with a timer. It presently maintains persistence through a crontab config file, but it looks like you need something more advanced, so you can take a look at the code, the core of it is just in one module ecrn_agent, and perhaps add a persistence layer. Alternatively, switching your existing implementation to store records in a mnesia disk table would likely be the easiest approach. Best, Serge
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions