scheduler

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: AGPL-3.0 Imports: 29 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scheduler contains code for the scheduler backend that handles managing background jobs for the application.

Index

Constants

This section is empty.

Variables

View Source
var New = sync.OnceValues(func() (*Manager, error) {
	logger := logging.New()

	osc, err := opensearch.GetClient()
	if err != nil {
		return nil, fmt.Errorf("get opensearch client: %w", err)
	}

	jobQueue, err := queue.NewJobQueue(logger, osc)
	if err != nil {
		return nil, fmt.Errorf("new job queue: %w", err)
	}

	scheduler, err := quartz.NewStdScheduler(
		quartz.WithWorkerLimit(runtime.GOMAXPROCS(0)),
		quartz.WithOutdatedThreshold(defaultOutdatedThreshold),
		quartz.WithRetryInterval(time.Second),
		quartz.WithQueue(jobQueue, &sync.Mutex{}),
		quartz.WithLogger(quartzlogger.NewSlogLogger(context.Background(), logger)),
	)
	if err != nil {
		return nil, fmt.Errorf("new scheduler: %w", err)
	}

	return &Manager{
		Scheduler: scheduler,
		queue:     jobQueue,
		osc:       osc,
	}, nil
})

New will create a Manager containing the scheduler and job queue. New does not start the scheduler; call Run() to start it. The returned Manager can however be used to manage jobs (schedule/delete/query jobs).

Functions

This section is empty.

Types

type Manager

type Manager struct {
	quartz.Scheduler
	// contains filtered or unexported fields
}

Manager contains data for managing a scheduler instance.

func (*Manager) ClearDeletedFeedJobs added in v0.261.0

func (m *Manager) ClearDeletedFeedJobs(ctx context.Context) error

ClearDeletedFeedJobs clears all jobs that are marked with their feed deleted.

func (*Manager) InitAdminJobs added in v0.235.0

func (m *Manager) InitAdminJobs(ctx context.Context) error

InitAdminJobs loads the listed jobs into the scheduler. These are administrative jobs that should always be scheduled.

func (*Manager) LoadUpdateFeedJobs added in v0.235.0

func (m *Manager) LoadUpdateFeedJobs(ctx context.Context, feedSvc *service.FeedService) error

LoadUpdateFeedJobs will ensure that all feeds have an update job scheduled.

func (*Manager) Shutdown added in v0.244.2

func (m *Manager) Shutdown(services *jobs.Services)

Shutdown performs shutdown logic for the scheduler, including safe shutdown of background services used by the scheduler and jobs.

func (Manager) Start added in v1.0.0

func (m Manager) Start(ctx context.Context) error

Start starts the scheduler, including setting up background services, loading context for job queue and initialising admin jobs.

func (*Manager) UpdateJob added in v0.261.0

func (m *Manager) UpdateJob(ctx context.Context, job *jobs.SerializedJob) error

UpdateJob updates a serialized job directly in the queue backend.

Directories

Path Synopsis
Package queue implements a quartz.JobQueue using Elasticsearch as the storage backend.
Package queue implements a quartz.JobQueue using Elasticsearch as the storage backend.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL