feat(api): add /v1/maintenance policies and run endpoints
OpenAPI, httpapi CRUD/run/dry-run, job maintenance_policy_run и audit с policy_id. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -8,14 +8,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"evobgp/internal/jobs"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
// StartScheduler enqueues maintenance_policy_run jobs when cron schedules match.
|
||||
func StartScheduler(ctx context.Context, provider *ConfigProvider, reg *jobs.Registry, tick time.Duration) {
|
||||
if provider == nil || reg == nil {
|
||||
func StartScheduler(ctx context.Context, provider *ConfigProvider, enqueue func(policyID string, dryRun bool, idempotencyKey string), tick time.Duration) {
|
||||
if provider == nil || enqueue == nil {
|
||||
return
|
||||
}
|
||||
if tick <= 0 {
|
||||
@@ -76,14 +74,8 @@ func StartScheduler(ctx context.Context, provider *ConfigProvider, reg *jobs.Reg
|
||||
continue
|
||||
}
|
||||
lastFired[p.ID] = next
|
||||
dry := p.DryRunEnabled
|
||||
idem := fmt.Sprintf("maint-%s-%d", p.ID, slot)
|
||||
key := idem
|
||||
_, _, _ = reg.Enqueue("", "maintenance_policy_run", &key, nil, map[string]any{
|
||||
"policy_id": p.ID,
|
||||
"dry_run": dry,
|
||||
"trigger": "scheduler",
|
||||
})
|
||||
enqueue(p.ID, p.DryRunEnabled, idem)
|
||||
}
|
||||
mu.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user