feat: initial Beta 1 release
- soju raw connector with event playback and CHATHISTORY fallback - SQLite store with msgid de-dup and retention job - Mentions + Pushover + tuning; structured JSON logs - Summaries: concise, link-following, multi-line grouping - HTTP: /healthz, /ready, /tail, /trigger, /metrics - Docker: distroless, healthcheck, version metadata - Docs: README, CHANGELOG, compose
This commit is contained in:
commit
2954e85e7a
19 changed files with 1983 additions and 0 deletions
31
internal/scheduler/scheduler.go
Normal file
31
internal/scheduler/scheduler.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
// Start runs the cron scheduler until ctx is done.
|
||||
func Start(ctx context.Context, spec string, job func(now time.Time), logger *log.Logger) error {
|
||||
c := cron.New(cron.WithParser(cron.NewParser(cron.SecondOptional|cron.Minute|cron.Hour|cron.Dom|cron.Month|cron.Dow|cron.Descriptor)))
|
||||
_, err := c.AddFunc(spec, func() {
|
||||
job(time.Now())
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if logger != nil {
|
||||
logger.Printf("scheduler started: %s", spec)
|
||||
}
|
||||
c.Start()
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
c.Stop()
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue