Description forĀ util.timer from v3.10.x onward.

The timer API in Metronome allows to perform asynchronous time based
operations by adding a callback to the server event loop which will fire
when the timer expires, there’re several ways to use the timers library
in Metronome’s code, you can require the library object by using:

require timer = “util.timer”;

Use the Module API, or require single API functions depending on what
you need to do. We’ll begin by describing the single API functions
exported by the library object:

All timers are otherwise enclosed into a simple dictionary called task_list exposed on the library object which entries contain delay, callback, origin and host
and are indexed by the timer’s UUID. You can traverse the list using
either pairs() or another custom iterator of your choice. Removing a
task from this table will have the same effect as calling any of the
removing API functions.

You can also create and remove tasks indirectly by using the Module
API functions, this has the advantage to auto-flag the timers, and
remove ’em when the module gets unloaded (or reloaded):

And finally to repeat a timer you just need the callback to return a number with the time in seconds before recalling it again.