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