package pact_test import ( "fmt" "time" "git.golem15.com/golem15/summercms/modules/pact" ) // BlogPlugin is the acme.blog plugin; only its schedule is shown here. type BlogPlugin struct{} var _ pact.HasSchedule = (*BlogPlugin)(nil) // Schedule runs three of the plugin's registered console commands. func (p *BlogPlugin) Schedule() []pact.ScheduledCommand { return []pact.ScheduledCommand{ {Command: "blog:prune-drafts", Cadence: pact.Daily()}, {Command: "blog:send-digest", Cadence: pact.DailyAt(7, 30)}, {Command: "blog:sync-feed", Args: []string{"--quiet"}, Cadence: pact.Every(15 * time.Minute)}, } } func ExampleHasSchedule() { var plugin pact.HasSchedule = &BlogPlugin{} for _, entry := range plugin.Schedule() { if hour, minute, daily := entry.Cadence.At(); daily { fmt.Printf("%s %v: daily at %02d:%02d\n", entry.Command, entry.Args, hour, minute) continue } fmt.Printf("%s %v: every %s\n", entry.Command, entry.Args, entry.Cadence.Interval()) } // Output: // blog:prune-drafts []: daily at 00:00 // blog:send-digest []: daily at 07:30 // blog:sync-feed [--quiet]: every 15m0s }