Skip to content

Instantly share code, notes, and snippets.

@rishabh-gupta2
Last active March 30, 2021 11:51
Show Gist options
  • Save rishabh-gupta2/75d52e69bd9423f00942e973fbd0898f to your computer and use it in GitHub Desktop.
Save rishabh-gupta2/75d52e69bd9423f00942e973fbd0898f to your computer and use it in GitHub Desktop.
Store interface
// Store provides an interface for persisting and reading jobs.
type Store interface {
// FindPendingJobsToProcess reads new jobs to be processed,
// and marks them as processing atomically.
FindPendingJobsToProcess(ctx context.Context, jobBatchSize int32, jobProcessingTimeout time.Duration) ([]*Job, error)
// FindFailedJobsToProcess reads failed jobs to be processed again,
// and marks them as processing atomically.
FindFailedJobsToProcess(ctx context.Context, jobBatchSize int32) ([]*Job, error)
// CreateJob persists a new job.
CreateJob(context.Context, *gorm.DB, *Job) error
// Delete deletes a processed job.
DeleteJob(ctx context.Context, jobID string) error
// Update updates a failed job, setting status and attempts info.
// Marks job as either JobStatusFailed or JobStatusRetryExhausted.
UpdateJob(context.Context, *Job) error
// RegisterMetrics registers prometheus metrics for Store interface.
RegisterMetrics(registerer prometheus.Registerer) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment