cron

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 14 Imported by: ? modules, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	Name() string

	// Lock returns a unique identifier for the job
	Lock() string

	// TenantID returns the tenant ID for the job
	TenantID() string

	// Schedule returns the cron schedule for the job (e.g., "0 * * * * *" for every minute)
	Schedule() string

	// Run executes the job and returns an error if it fails
	Run(ctx context.Context) error

	// NextRunTime returns when this job should run next (optional)
	// This is used for tracking in the cron_jobs table
	NextRunTime() time.Time

	// IsLongRunning returns true if this job typically runs longer than 5 minutes
	// This enables heartbeat updates during execution
	IsLongRunning() bool
}

Job defines the interface that all scheduled jobs must implement

type JobManager

type JobManager struct {
	// contains filtered or unexported fields
}

func InitJobManager

func InitJobManager(ctx context.Context, connPool *pgxpool.Pool) *JobManager

InitJobManager initializes the singleton JobManager instance

func (*JobManager) Register

func (jm *JobManager) Register(job Job) error

Register adds a job to the job manager. A schedule the cron parser rejects is refused: the job is not scheduled, the reason is stored as registration_error on its cron_registered_jobs row, and it is returned. A failure to write that row is returned too, though a valid job is still scheduled.

func (*JobManager) RegisterJob

func (jm *JobManager) RegisterJob(job Job)

RegisterJob adds a job to the job manager. A failure is logged and recorded on the job's cron_registered_jobs row; use Register to receive it as an error.

func (*JobManager) StartScheduler

func (jm *JobManager) StartScheduler()

StartScheduler starts the cron scheduler with concurrency control

func (*JobManager) StopScheduler

func (jm *JobManager) StopScheduler()

StopScheduler stops the cron scheduler

func (*JobManager) UnregisterJob

func (jm *JobManager) UnregisterJob(jobName string, tenantID string)

UnregisterJob removes a job from the job manager

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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