added a periodic worker

The periodic worker will call a function periodically based on an input duration
this should be a defer, called at the very top of the func