database

package module
v0.0.0-...-3e6a4a8 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailedJob

type FailedJob struct {
	ID        uint64              `gorm:"column:id;autoIncrement;primaryKey;not null"`
	Queue     string              `gorm:"column:queue;not null"`
	Payload   queue.Queueable     `gorm:"column:payload;serializer:json;not null"`
	Exception exception.Throwable `gorm:"column:exception"`
	FailedAt  time.Time           `gorm:"column:failed_at;not null;autoCreateTime"`
}

FailedJob failed job model

func (*FailedJob) Query

func (f *FailedJob) Query(table string) FailedJobDAO

Query query

type FailedJobDAO

type FailedJobDAO struct {
	dao.DAO[FailedJob]

	ID        field.Uint64
	Queue     field.String
	Payload   field.String
	Exception field.String
	FailedAt  field.Time
}

FailedJobDAO failed job dao

type Failer

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

Failer failer

func (*Failer) All

func (f *Failer) All(queue string) support.List[queuecontract.Job]

All all

func (*Failer) Find

func (f *Failer) Find(queue string, id uuid.UUID) queuecontract.Job

Find find

func (*Failer) Flush

func (f *Failer) Flush(queue string)

Flush flush

func (*Failer) Forget

func (f *Failer) Forget(queue string, id uuid.UUID)

Forget forget

func (*Failer) Save

func (f *Failer) Save(queue string, job queuecontract.Job, err error)

Save save

type Job

type Job struct {
	dao.DAO[Job] `gorm:"-"`

	JobID       uint64     `gorm:"column:id;autoIncrement;primaryKey;not null"`
	JobUUID     uuid.UUID  `gorm:"column:uuid;uniqueIndex;not null"`
	Queue       string     `gorm:"column:queue;not null"`
	JobPayload  queue.Job  `gorm:"column:payload;serializer:json;not null"`
	JobAttempts uint8      `gorm:"column:attempts;default:0"`
	ReservedAt  *time.Time `gorm:"column:reserved_at"`
	AvaliableAt *time.Time `gorm:"column:avaliable_at;not null"`
	CreatedAt   *time.Time `gorm:"column:created_at;not null;autoCreateTime"`
}

Job job model

func (*Job) Attempts

func (j *Job) Attempts() uint

Attempts attempts

func (Job) Fields

func (j Job) Fields(table string) JobDAO

Fields fields

func (*Job) ID

func (j *Job) ID() uint64

ID id

func (*Job) Payload

func (j *Job) Payload() queue.Job

Payload payload

func (*Job) UUID

func (j *Job) UUID() uuid.UUID

UUID uuid

type JobDAO

type JobDAO struct {
	dao.DAO[Job]

	ID          field.Uint64
	UUID        field.String
	Queue       field.String
	Payload     field.String
	Attempts    field.Uint8
	ReservedAt  field.Time
	AvaliableAt field.Time
	CreatedAt   field.Time
}

JobDAO job dao

type Queue

type Queue struct {
	queue.AbstractQueue
	// contains filtered or unexported fields
}

Queue queue

func New

func New(name string, connection *database.Connection, table string, failer queue.Failer) *Queue

New new queue

func (*Queue) Ack

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

Ack acks a job

func (*Queue) Count

func (q *Queue) Count() int64

Count returns the count of pending jobs

func (*Queue) Dequeue

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

Dequeue pops a job from queue

func (*Queue) Enqueue

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

Enqueue pushes a job to queue

func (*Queue) Fail

func (q *Queue) Fail(job queue.Job, err error)

Fail handles a failed job

func (*Queue) Flush

func (q *Queue) Flush()

Flush removes all failed jobs

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

IsEmpty returns if the count of pending jobs is zero

func (*Queue) Name

func (q *Queue) Name() string

Name return queue name

func (*Queue) Progress

func (q *Queue) Progress() (pending int64, executing int64)

Progress progress

func (*Queue) Reload

func (q *Queue) Reload()

Reload reloads all failed jobs into queue

func (*Queue) Remove

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

Remove removes a job from queue

Jump to

Keyboard shortcuts

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