# cycle-scheduler cycle-scheduler is a simple scheduler handling jobs and executes them at regular interval. Here a simple representation: ```ascii +------------------------------------------------------+ | +---+ +---+ +---+ +---+ +---+ +---+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |s1 | |s2 | |s3 | |s4 | | | |s60| | | +---+ +---+ +---+ +---+ +---+ +---+ | +---------------^--------------------------------------+ ``` Jobs are handle in a array of job slices. At each interval (clock), the cursor `^` moves to the next slot (s*). If there are jobs, they are sent to workers to be executed and the slot is cleaned. At the end of the slot (s60), the cursor re-starts a new cycle from s1. If a job is not in a desire state, the job is re-scheduled in the current slot to be re-executed in the next cycle. **NOTE**: This scheduler does not accept long running tasks. Job execution have a fixed timeout of 10s. Pooling tasks are more suitable for this kind of scheduler. ## Run You can run sample tests from `main.go` to see the scheduler in action: ```bash make run ``` If all goes well, you should see this kind of output in the stdout: ```ascii # cycle-scheduler (slot: 7) _ P _ _ _ _ _ _ _ _ _ _ _ _ - - - - - - ^ - - - - - - - ``` > **P** means *pending* state You can adjust the clock interval as needed in `main.go`: ```go interval := 200 * time.Millisecond ```