chore: update memo payload runner schedule

This commit is contained in:
johnnyjoy 2024-12-26 20:01:15 +08:00
parent 41d9c9d76e
commit 3b0be442de
2 changed files with 2 additions and 19 deletions

View File

@ -4,7 +4,6 @@ import (
"context"
"log/slog"
"slices"
"time"
"github.com/pkg/errors"
"github.com/usememos/gomark/ast"
@ -25,23 +24,7 @@ func NewRunner(store *store.Store) *Runner {
}
}
// Schedule runner every 12 hours.
const runnerInterval = time.Hour * 12
func (r *Runner) Run(ctx context.Context) {
ticker := time.NewTicker(runnerInterval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
r.RunOnce(ctx)
case <-ctx.Done():
return
}
}
}
// RunOnce rebuilds the payload of all memos.
func (r *Runner) RunOnce(ctx context.Context) {
memos, err := r.Store.ListMemos(ctx, &store.FindMemo{})
if err != nil {

View File

@ -147,11 +147,11 @@ func (s *Server) StartBackgroundRunners(ctx context.Context) {
versionRunner := version.NewRunner(s.Store, s.Profile)
versionRunner.RunOnce(ctx)
memopayloadRunner := memopayload.NewRunner(s.Store)
// Rebuild all memos' payload after server starts.
memopayloadRunner.RunOnce(ctx)
go s3presignRunner.Run(ctx)
go versionRunner.Run(ctx)
go memopayloadRunner.Run(ctx)
}
func (s *Server) getOrUpsertWorkspaceBasicSetting(ctx context.Context) (*storepb.WorkspaceBasicSetting, error) {