2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 02:02:14 +00:00
Paul Cleary 933614ed37
Generic Task Scheduler (#717)
Creates a more general task scheduler.  The existing user sync process had some half generic pieces, and other pieces that were tightly coupled to the user sync process.

This is the first step at making a general purpose task scheduler.  This has been proven out in the implementation of the user sync process in #718 

1. `TaskRepository` - renamed `pollingInterval` to `taskTimeout` as the value is similar to `visbilityTimeout` in SQS

2. `Task` - is an interface that needs to be implemented by future tasks.   `name` is the unique name of the task; `timeout` is how long to wait to consider the last claim expired; `runEvery` is how often to attempt to run the task; `run()` is the function that actually executes the task itself.

3. `TaskScheduler` - this is the logic of scheduling.  It embodies the logic of a) saving the task b) claiming the task c) running the task and d) releasing the task.  It uses `IO.bracket` to make sure the finalizer `releaseTask` is called no matter what the result is of running the task.  It uses `fs2.Stream.awakeEvery` for polling.  The expectation is that the caller will acquire the stream and do an `Stream.compile.drain.start` to kick it off running.  It can be cancelled using the `Fiber` returned from `Stream.compile.drain.start`
2019-07-01 13:53:00 -04:00
..
2018-10-09 11:30:16 -04:00
2018-09-20 10:58:04 -04:00
2018-08-16 14:04:22 -04:00