populator v0.5.0 Populator.Looper

Summary

Functions

Start a looper that runs Populator.run/3 on every loop. Example

Functions

run(args)

Start a looper that runs Populator.run/3 on every loop. Example:

  Populator.Looper.run step: 30000, name: :my_looper, run_args: run_args

To be added to a supervisor hierarchy wrapped in a Task, like this:

  worker(Task, [Populator.Looper,:run,[args]])
  • run_args are the arguments expected by Populator.run/3
  • max_loops below zero implies forever loop (default -1). :ok is returned if :max_loops reached.
  • step is in milliseconds, time to sleep between loops (default 30000)
  • name is the name to be registered with (not given means not registered)

    State can be accessed using an Agent registered as :my_looper_agent ("#{args[:name]}_agent").

    This can be useful if you need to change any of the given arguments after the loop is started. Any changes over that state are used in the next iteration of the loooper. Agent updates are atomic, so any update you will be fully applied, or no applied at all (i.e. will be applied from the next iteration on).