// Package redisqueue provides a Redis-backed job queue for async processing. package redisqueue import ( "errors" "time" ) // Job represents an async job in the queue. type Job struct { ID string `json:"id"` Type string `json:"type"` Payload map[string]any `json:"payload"` Status JobStatus `json:"status"` CreatedAt time.Time `json:"created_at"` StartedAt *time.Time `json:"started_at,omitempty"` CompletedAt *time.Time `json:"completed_at,omitempty"` Error string `json:"error,omitempty"` } // JobStatus represents the current state of a job. type JobStatus string const ( StatusPending JobStatus = "pending" StatusRunning JobStatus = "running" StatusCompleted JobStatus = "completed" StatusFailed JobStatus = "failed" ) // String returns the string representation of the status. func (s JobStatus) String() string { return string(s) } // Sentinel errors. var ( // ErrNoJob is returned when the queue has no pending jobs. ErrNoJob = errors.New("no job available") // ErrJobNotFound is returned when a job ID doesn't exist. ErrJobNotFound = errors.New("job not found") )