Documentation ¶
Overview ¶
Package database implements a queue driver that uses a database to store the queue.
Index ¶
- Constants
- func Open(options map[string]any) (queuecontract.Queue, error)
- type Config
- type Driver
- type Job
- type Option
- type Queue
- func (q *Queue) Ack(job queue.Job)
- func (q *Queue) Count() int64
- func (q *Queue) Dequeue() (queue.Job, bool)
- func (q *Queue) Empty() bool
- func (q *Queue) Enqueue(job queue.Job) (queue.Job, bool)
- func (q *Queue) Name() string
- func (q *Queue) Release(job queue.Job)
- func (q *Queue) Remove(job queue.Job)
Constants ¶
View Source
const ( ColumnID = "id" ColumnQueue = "queue" ColumnPayload = "payload" ColumnReservedAt = "reserved_at" ColumnAvailableAt = "available_at" ColumnCreatedAt = "created_at" ColumnUpdatedAt = "updated_at" )
column names for Job Table
View Source
const DefaultJobTable = "jobs"
DefaultJobTable is the default Table name for jobs.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(options map[string]any) (queuecontract.Queue, error)
Open is a convenience function that calls Driver.Open.
Types ¶
type Config ¶
Config is the configuration for database queue.
type Job ¶
type Job struct { ID uuid.UUID `gorm:"column:id;primaryKey" json:"id"` Queue string `gorm:"column:queue" json:"queue"` Payload queue.Job `gorm:"column:payload;serializer:json" json:"payload"` Attempts int `gorm:"column:attempts" json:"attempts"` ReservedAt sql.Null[time.Time] `gorm:"column:reserved_at" json:"reserved_at"` AvailableAt time.Time `gorm:"column:available_at" json:"available_at"` CreatedAt time.Time `gorm:"column:created_at" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"` }
Job is a database queue job, it is a wrapper around the [queue.Job]
func (*Job) GetAttempts ¶
GetAttempts returns how many times the job has been attempted
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is database backed queue implementation
Click to show internal directories.
Click to hide internal directories.