import "github.com/its-ernest/rundown-workers/cmd/worker"type CompleteRequest
CompleteRequest identifies a job to be marked as finished.
type CompleteRequest struct {
ID string `json:"id"`
}type EnqueueRequest
EnqueueRequest defines the parameters for adding a new job to a queue.
type EnqueueRequest struct {
Queue string `json:"queue"`
Payload string `json:"payload"`
Timeout int `json:"timeout"`
MaxRetries int `json:"max_retries"`
}type FailRequest
FailRequest identifies a job to be marked as failed.
type FailRequest struct {
ID string `json:"id"`
}type PollRequest
PollRequest defines the queue to poll for new jobs.
type PollRequest struct {
Queue string `json:"queue"`
}import "github.com/its-ernest/rundown-workers/internal/store"- type SQLiteStore
- func NewSQLiteStore(dbPath string) (*SQLiteStore, error)
- func (s *SQLiteStore) CleanupStale() (int64, error)
- func (s *SQLiteStore) Complete(id string) error
- func (s *SQLiteStore) Enqueue(queue, payload string, timeout, maxRetries int) (*engine.Job, error)
- func (s *SQLiteStore) Fail(id string) error
- func (s *SQLiteStore) Poll(queue string) (*engine.Job, error)
- type Store
type SQLiteStore
SQLiteStore provides a lightweight persistent storage implementation using SQLite.
It is designed to handle multiple worker processes safely using IMMEDIATE transactions for polling.
type SQLiteStore struct {
// contains filtered or unexported fields
}func NewSQLiteStore
func NewSQLiteStore(dbPath string) (*SQLiteStore, error)NewSQLiteStore initializes a new Store and runs all necessary schema migrations.
func (*SQLiteStore) CleanupStale
func (s *SQLiteStore) CleanupStale() (int64, error)func (*SQLiteStore) Complete
func (s *SQLiteStore) Complete(id string) errorfunc (*SQLiteStore) Enqueue
func (s *SQLiteStore) Enqueue(queue, payload string, timeout, maxRetries int) (*engine.Job, error)func (*SQLiteStore) Fail
func (s *SQLiteStore) Fail(id string) errorfunc (*SQLiteStore) Poll
func (s *SQLiteStore) Poll(queue string) (*engine.Job, error)type Store
Store defines the required operations for job persistence and lifecycle management.
type Store interface {
// Enqueue adds a new job to the specified queue.
Enqueue(queue, payload string, timeout, maxRetries int) (*engine.Job, error)
// Poll picks the oldest pending job that is ready to run.
Poll(queue string) (*engine.Job, error)
Complete(id string) error
Fail(id string) error
CleanupStale() (int64, error)
}import "github.com/its-ernest/rundown-workers/pkg/engine"type Job
Job is the primary unit of work in Rundown-Workers.
It contains the payload to be processed, the current status, and metadata required for retry logic and timeout enforcement.
type Job struct {
ID string `json:"id"`
Queue string `json:"queue"`
Payload string `json:"payload"`
Status JobStatus `json:"status"`
Retries int `json:"retries"` // How many times this job has been attempted.
MaxRetries int `json:"max_retries"` // Maximum allowed retries before moving to StatusFailed.
Timeout int `json:"timeout"` // Total seconds allowed for execution before being marked stale.
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
NextRunAt time.Time `json:"next_run_at"` // The time when the job is eligible to be picked up again (for retries).
}type JobStatus
JobStatus represents the current lifecycle state of a workflow job.
type JobStatus stringconst (
// StatusPending means the job is in the queue and waiting for a worker.
StatusPending JobStatus = "pending"
// StatusRunning means a worker has picked up the job and is currently executing it.
StatusRunning JobStatus = "running"
// StatusDone means the job completed successfully.
StatusDone JobStatus = "done"
// StatusFailed means the job failed all retry attempts or was marked as fatal.
StatusFailed JobStatus = "failed"
)Generated by gomarkdoc