vieter/src/cron/cron.v

34 lines
563 B
Coq
Raw Normal View History

2022-04-09 09:46:07 +02:00
module cron
import git
import datatypes
import time
2022-04-12 11:10:49 +02:00
import rand
struct ScheduledBuild {
repo git.GitRepo
timestamp time.Time
}
fn (r1 ScheduledBuild) < (r2 ScheduledBuild) bool {
return r1.timestamp < r2.timestamp
}
2022-04-09 09:46:07 +02:00
pub fn cron(conf Config) ? {
2022-04-12 11:10:49 +02:00
mut queue := datatypes.MinHeap<time.Time>{}
2022-04-12 11:10:49 +02:00
for _ in 0..5000 {
minute := rand.int_in_range(0, 60) ?
hour := rand.int_in_range(0, 23) ?
ce := parse_expression('$minute $hour') ?
2022-04-12 11:10:49 +02:00
t := ce.next_from_now() ?
// println(t)
queue.insert(t)
2022-04-11 22:16:31 +02:00
}
2022-04-12 11:10:49 +02:00
for queue.len() > 0 {
println(queue.pop() ?)
2022-04-11 22:16:31 +02:00
}
2022-04-09 09:46:07 +02:00
}