mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Feature: add cron setting for the ldap settings * Move ldap configuration read to special function * Introduce cron setting (no docs for it yet, pending approval) * Chore: duplicate ldap module as a service * Feature: implement active sync This is very early preliminary implementation of active sync. There is only one thing that's going right for this code - it works. Aside from that, there is no tests, error handling, docs, transactions, it's very much duplicative and etc. But this is the overall direction with architecture I'm going for * Chore: introduce login service * Chore: gradually switch to ldap service * Chore: use new approach for auth_proxy * Chore: use new approach along with refactoring * Chore: use new ldap interface for auth_proxy * Chore: improve auth_proxy and subsequently ldap * Chore: more of the refactoring bits * Chore: address comments from code review * Chore: more refactoring stuff * Chore: make linter happy * Chore: add cron dep for grafana enterprise * Chore: initialize config package var * Chore: disable gosec for now * Chore: update dependencies * Chore: remove unused module * Chore: address review comments * Chore: make linter happy
28 lines
934 B
Go
28 lines
934 B
Go
package cron
|
|
|
|
import "time"
|
|
|
|
// ConstantDelaySchedule represents a simple recurring duty cycle, e.g. "Every 5 minutes".
|
|
// It does not support jobs more frequent than once a second.
|
|
type ConstantDelaySchedule struct {
|
|
Delay time.Duration
|
|
}
|
|
|
|
// Every returns a crontab Schedule that activates once every duration.
|
|
// Delays of less than a second are not supported (will round up to 1 second).
|
|
// Any fields less than a Second are truncated.
|
|
func Every(duration time.Duration) ConstantDelaySchedule {
|
|
if duration < time.Second {
|
|
duration = time.Second
|
|
}
|
|
return ConstantDelaySchedule{
|
|
Delay: duration - time.Duration(duration.Nanoseconds())%time.Second,
|
|
}
|
|
}
|
|
|
|
// Next returns the next time this should be run.
|
|
// This rounds so that the next activation time will be on the second.
|
|
func (schedule ConstantDelaySchedule) Next(t time.Time) time.Time {
|
|
return t.Add(schedule.Delay - time.Duration(t.Nanosecond())*time.Nanosecond)
|
|
}
|