gormoutbox

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutboxStatusPending = "pending"
	OutboxStatusSent    = "sent"
	OutboxStatusFailed  = "failed"
)

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db *gorm.DB) error

func MigrateOutbox

func MigrateOutbox(ctx context.Context, db *gorm.DB) error

Types

type GormOutbox

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

func New

func New(db *gorm.DB, client corequeue.Client) *GormOutbox

func NewGormOutbox

func NewGormOutbox(db *gorm.DB, client corequeue.Client) *GormOutbox

func (*GormOutbox) Flush

func (o *GormOutbox) Flush(ctx context.Context, limit int) error

func (*GormOutbox) Save

func (o *GormOutbox) Save(ctx context.Context, task corequeue.Task, opts ...corequeue.Option) error

func (*GormOutbox) SaveBatch

func (o *GormOutbox) SaveBatch(ctx context.Context, tasks ...corequeue.OutboxTask) error

type OutboxRecord

type OutboxRecord struct {
	ID          uint64         `json:"id" gorm:"primaryKey;autoIncrement;comment:主键"`
	TaskID      string         `json:"task_id" gorm:"column:task_id;size:191;index;comment:任务ID"`
	Queue       string         `json:"queue" gorm:"column:queue;size:64;not null;index:idx_queue_outbox_status_available,priority:2;comment:队列"`
	Type        string         `json:"type" gorm:"column:type;size:191;not null;index;comment:任务类型"`
	Payload     datatypes.JSON `json:"payload" gorm:"column:payload;type:jsonb;not null;comment:任务载荷"`
	Headers     datatypes.JSON `json:"headers" gorm:"column:headers;type:jsonb;not null;default:'{}'::jsonb;comment:任务头"`
	Options     datatypes.JSON `json:"options" gorm:"column:options;type:jsonb;not null;default:'{}'::jsonb;comment:投递选项"`
	Status      string         `json:"status" gorm:"column:status;size:32;not null;index:idx_queue_outbox_status_available,priority:1;comment:状态"`
	Attempts    int            `json:"attempts" gorm:"column:attempts;not null;default:0;comment:投递尝试次数"`
	LastError   string         `json:"last_error" gorm:"column:last_error;type:text;comment:最后错误"`
	AvailableAt time.Time      `` /* 130-byte string literal not displayed */
	SentAt      *time.Time     `json:"sent_at" gorm:"column:sent_at;comment:投递成功时间"`
	CreatedAt   time.Time      `json:"created_at,omitempty" gorm:"column:created_at;comment:创建时间"`
	UpdatedAt   time.Time      `json:"updated_at,omitempty" gorm:"column:updated_at;comment:更新时间"`
}

func (OutboxRecord) TableName

func (OutboxRecord) TableName() string

Jump to

Keyboard shortcuts

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