database

package module
v0.0.0-...-f9508f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptKeyConnection = "connection"
	OptKeyName       = "name"
	OptKeyTable      = "table"
)
View Source
const (
	ColumnID          = "id"
	ColumnQueue       = "queue"
	ColumnPayload     = "payload"
	ColumnReservedAt  = "reserved_at"
	ColumnAvaliableAt = "avaliable_at"
	ColumnCreatedAt   = "created_at"
	ColumnUpdatedAt   = "updated_at"
)
View Source
const (
	DefaultJobTable = "jobs"
)

Variables

View Source
var ErrMissingOptionConnection = errors.New("missing option \"connection\"")
View Source
var ErrMissingOptionName = errors.New("missing option \"name\"")

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(db *gorm.DB, name string) *Config

func ParseCfg

func ParseCfg(options map[string]any) (*Config, error)

func (*Config) Apply

func (cfg *Config) Apply(opts ...Option) error

func (*Config) FormatOpts

func (cfg *Config) FormatOpts() map[string]any

type Driver

type Driver struct{}

func (Driver) Open

func (d Driver) Open(options map[string]any) (qc.Queue, error)

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"`
	AvaliableAt time.Time           `gorm:"column:avaliable_at" json:"avaliable_at"`
	CreatedAt   time.Time           `gorm:"column:created_at" json:"created_at"`
	UpdatedAt   time.Time           `gorm:"column:updated_at" json:"updated_at"`
}

func NewJob

func NewJob(queue string, payload queue.Job) *Job

func (*Job) GetAttempts

func (d *Job) GetAttempts() int

func (*Job) GetID

func (d *Job) GetID() string

func (*Job) GetPayload

func (d *Job) GetPayload() queue.Job

func (*Job) GetQueue

func (d *Job) GetQueue() string

type Option

type Option func(cfg *Config) error

func Table

func Table(table string) Option

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(cfg *Config) *Queue

func (*Queue) Ack

func (q *Queue) Ack(job queue.Job)

func (*Queue) Count

func (q *Queue) Count() int64

func (*Queue) Dequeue

func (q *Queue) Dequeue() queue.Job

func (*Queue) Empty

func (q *Queue) Empty() bool

func (*Queue) Enqueue

func (q *Queue) Enqueue(job queue.Job)

func (*Queue) Name

func (q *Queue) Name() string

func (*Queue) Release

func (q *Queue) Release(job queue.Job, delay time.Duration)

func (*Queue) Remove

func (q *Queue) Remove(job queue.Job)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL