- architecture: introduction, Go modules and workspaces, application lifecycle, request lifecycle - plugins: registration, scheduling, extending, testing - verified Examples for backpack services, towel request context, pact schedules and festival events - TestDocsRequiredPages lists the eight new pages
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
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
|
|
}
|