Help us shape the future of Go! Take the 2026 Go Developer Survey

task

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package task holds the task bookkeeping rows (the task and task_error tables) and the scope and content of the batch email and quota gift tasks they record.

Index

Constants

View Source
const (
	Undefined Type = -1
	TypeEmail      = iota
	TypeQuota
)
View Source
const (
	StatusPending int8 = iota
	StatusInProgress
	StatusCompleted
	StatusFailed
	StatusCancelled
	StatusEnqueueFailed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailContent

type EmailContent struct {
	Subject string `json:"subject"`
	Content string `json:"content"`
}

func (*EmailContent) Marshal

func (c *EmailContent) Marshal() ([]byte, error)

func (*EmailContent) Unmarshal

func (c *EmailContent) Unmarshal(data []byte) error

type EmailScope

type EmailScope struct {
	requestmeta.Metadata
	Type              int8     `gorm:"not null;comment:Scope Type"`
	RegisterStartTime int64    `json:"register_start_time"`
	RegisterEndTime   int64    `json:"register_end_time"`
	Recipients        []string `json:"recipients"` // list of email addresses
	Additional        []string `json:"additional"` // additional email addresses
	Scheduled         int64    `json:"scheduled"`  // scheduled time (unix timestamp)
	Interval          uint8    `json:"interval"`   // interval in seconds
	Limit             uint64   `json:"limit"`      // daily send limit
	DailySent         uint64   `json:"daily_sent,omitempty"`
	DailyDate         string   `json:"daily_date,omitempty"`
}

func (*EmailScope) Marshal

func (s *EmailScope) Marshal() ([]byte, error)

func (*EmailScope) Unmarshal

func (s *EmailScope) Unmarshal(data []byte) error

type Filter

type Filter struct {
	Type   Type
	Page   int
	Size   int
	Status *uint8
	Scope  *int8
}

Filter selects a page of the task list.

type QuotaContent

type QuotaContent struct {
	ResetTraffic bool   `json:"reset_traffic"`        // whether to reset traffic
	Days         uint64 `json:"days,omitempty"`       // days to add
	GiftType     uint8  `json:"gift_type,omitempty"`  // 1: Fixed, 2: Ratio
	GiftValue    uint64 `json:"gift_value,omitempty"` // value of the gift type
}

func (*QuotaContent) Marshal

func (c *QuotaContent) Marshal() ([]byte, error)

func (*QuotaContent) Unmarshal

func (c *QuotaContent) Unmarshal(data []byte) error

type QuotaScope

type QuotaScope struct {
	requestmeta.Metadata
	Subscribers []int64 `json:"subscribers"` // Subscribe IDs
	IsActive    *bool   `json:"is_active"`   // filter by active status
	StartTime   int64   `json:"start_time"`  // filter by subscription start time
	EndTime     int64   `json:"end_time"`    // filter by subscription end time
	Objects     []int64 `json:"recipients"`  // list of user subs IDs
}

func (*QuotaScope) Marshal

func (s *QuotaScope) Marshal() ([]byte, error)

func (*QuotaScope) Unmarshal

func (s *QuotaScope) Unmarshal(data []byte) error

type ScopeType

type ScopeType int8
const (
	ScopeAll     ScopeType = iota + 1 // All users
	ScopeActive                       // Active users
	ScopeExpired                      // Expired users
	ScopeNone                         // No Subscribe
	ScopeSkip                         // Skip user filtering
)

func ParseScopeType

func ParseScopeType(t int8) ScopeType

func (ScopeType) Int8

func (t ScopeType) Int8() int8

type Task

type Task struct {
	Id        int64     `gorm:"primaryKey;autoIncrement;comment:ID"`
	Type      int8      `gorm:"not null;comment:Task Type"`
	Scope     string    `gorm:"type:text;comment:Task Scope"`
	Content   string    `gorm:"type:text;comment:Task Content"`
	Status    int8      `` /* 131-byte string literal not displayed */
	Errors    string    `gorm:"type:text;comment:Task Errors"`
	Total     uint64    `gorm:"column:total;not null;default:0;comment:Total Number"`
	Current   uint64    `gorm:"column:current;not null;default:0;comment:Current Number"`
	DailyDate string    `gorm:"type:varchar(10);not null;default:'';comment:Email daily quota date"`
	DailySent uint64    `gorm:"not null;default:0;comment:Email daily quota sent count"`
	CreatedAt time.Time `gorm:"<-:create;comment:Creation Time"`
	UpdatedAt time.Time `gorm:"comment:Update Time"`
}

func (Task) TableName

func (Task) TableName() string

type TaskError added in v1.19.0

type TaskError struct {
	Id         int64     `gorm:"primaryKey;autoIncrement;comment:ID"`
	TaskId     int64     `gorm:"not null;uniqueIndex:uk_task_error_position;index:idx_task_error_task_id;comment:Task ID"`
	Position   uint64    `gorm:"not null;uniqueIndex:uk_task_error_position;comment:Target position"`
	Target     string    `gorm:"type:varchar(320);not null;default:'';comment:Failed target"`
	Error      string    `gorm:"type:text;comment:Failure reason"`
	OccurredAt int64     `gorm:"not null;default:0;comment:Failure unix timestamp"`
	CreatedAt  time.Time `gorm:"<-:create;comment:Creation Time"`
}

TaskError stores one durable execution failure without repeatedly rewriting the task.Errors JSON document as a campaign grows.

func (TaskError) TableName added in v1.19.0

func (TaskError) TableName() string

type Type

type Type int8

Jump to

Keyboard shortcuts

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