Documentation
¶
Index ¶
- Constants
- Variables
- type ContextKey
- type Partition
- type PartitionList
- type PartitionListRequest
- type PartitionMeta
- type PartitionName
- type PartitionSeq
- type PartitionSeqRequest
- type Queue
- type QueueCleanRequest
- type QueueCleanResponse
- type QueueList
- type QueueListRequest
- type QueueMeta
- type QueueName
- type QueueStatusRequest
- type QueueStatusResponse
- type QueueWithStatus
- type Task
- type TaskFunc
- type TaskId
- type TaskList
- type TaskListRequest
- type TaskMeta
- type TaskRelease
- type TaskRetain
- type TaskWithStatus
- type Ticker
- type TickerList
- type TickerListRequest
- type TickerMeta
- type TickerName
- type TickerNext
Constants ¶
const ( DefaultSchema = "pgqueue" DefaultNotifyChannel = "queue_notify" QueueListLimit = 100 TickerListLimit = 100 DefaultPartitionSize = 100_000 // tasks per partition DefaultPartitionThreshold = 0.5 // create partition(s) when sequence reaches this fraction of the highest partition end DefaultPartitionAhead = 1 // number of partition(s) to create when threshold is reached DefaultMaintenanceTickerName = "$maintenance$" DefaultCleanupTickerName = "$cleanup$" DefaultTickerPeriod = 5 * time.Second // how often to look for matured tickers DefaultQueuePeriod = 10 * time.Second // how often to poll queues for retries and missed notifications DefaultCleanupPeriod = 15 * time.Minute // how often to delete expired tasks DefaultMaintenancePeriod = 10 * time.Minute // create and drop partitions DefaultRetention = 24 * time.Hour // how long finished tasks are kept before they're cleaned QueueCleanLimit = 100 // the most tasks cleaned from a queue at once, as in queue_clean )
Variables ¶
var Objects string
var Queries string
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶ added in v1.4.0
type ContextKey int
ContextKey is the type of the keys of the values in the context of a task or ticker callback
const ( // ContextKeyTask is the key of the task, a *Task, in the context of a // queue's task callback ContextKeyTask ContextKey = iota // ContextKeyTicker is the key of the ticker, a *Ticker, in the context of // a ticker's callback ContextKeyTicker )
type Partition ¶
type Partition struct {
PartitionMeta
Count uint64 `json:"count" db:"count"`
}
type PartitionList ¶
type PartitionList struct {
Body []Partition `json:"body,omitempty"`
}
func (PartitionList) String ¶
func (p PartitionList) String() string
type PartitionListRequest ¶
type PartitionListRequest struct{}
func (PartitionListRequest) String ¶
func (p PartitionListRequest) String() string
type PartitionMeta ¶
type PartitionMeta struct {
Partition string `json:"partition" db:"partition"`
Start uint64 `json:"start" db:"start"`
End uint64 `json:"end" db:"end"`
}
func (PartitionMeta) String ¶
func (p PartitionMeta) String() string
type PartitionName ¶
type PartitionName string
func (PartitionName) String ¶
func (p PartitionName) String() string
type PartitionSeq ¶
type PartitionSeq uint64
func (PartitionSeq) String ¶
func (p PartitionSeq) String() string
type PartitionSeqRequest ¶
type PartitionSeqRequest struct {
Min uint64 `json:"min,omitempty"`
}
PartitionSeqRequest gets the sequence for the task table, and raises it to the minimum first, when it's set and the sequence is lower
func (PartitionSeqRequest) String ¶
func (p PartitionSeqRequest) String() string
type QueueCleanRequest ¶
type QueueCleanRequest struct {
Queue string `json:"queue,omitempty" arg:"" help:"Queue name"`
Retention time.Duration `json:"retention,omitempty" help:"How long finished tasks are kept"`
}
func (QueueCleanRequest) String ¶
func (q QueueCleanRequest) String() string
type QueueCleanResponse ¶
type QueueCleanResponse struct {
QueueCleanRequest
Body []Task `json:"body,omitempty"`
}
func (QueueCleanResponse) String ¶
func (q QueueCleanResponse) String() string
type QueueList ¶
type QueueList struct {
QueueListRequest
Count uint64 `json:"count"`
Body []QueueWithStatus `json:"body,omitempty"`
}
type QueueListRequest ¶
type QueueListRequest struct {
pg.OffsetLimit
}
func (QueueListRequest) Query ¶ added in v1.4.0
func (q QueueListRequest) Query() url.Values
Query returns the request as URL query parameters
func (QueueListRequest) String ¶
func (q QueueListRequest) String() string
type QueueMeta ¶
type QueueMeta struct {
TTL *time.Duration `json:"ttl,omitempty" help:"Time-to-live for queue messages"`
Retries *uint64 `json:"retries" help:"Number of retries before failing"`
RetryDelay *time.Duration `json:"retry_delay" help:"Backoff delay"`
Concurrency *uint64 `json:"concurrency" help:"Number of concurrent workers"`
Dedupe *bool `json:"dedupe,omitempty" help:"Whether a task is not inserted while the same task is pending"`
}
type QueueStatusRequest ¶
type QueueStatusRequest struct {
Queue string `json:"queue,omitempty"`
}
QueueStatusRequest gets a queue with the number of its tasks with each status, or lists every queue with them
type QueueStatusResponse ¶
type QueueStatusResponse struct {
QueueStatusRequest
Body []QueueWithStatus `json:"body,omitempty"`
}
func (QueueStatusResponse) String ¶
func (q QueueStatusResponse) String() string
type QueueWithStatus ¶ added in v1.4.3
type QueueWithStatus struct {
Queue
New uint64 `json:"new" help:"Tasks which are ready to run"`
Running uint64 `json:"running" help:"Tasks which are running"`
Retry uint64 `json:"retry" help:"Tasks which are waiting to be retried"`
Expired uint64 `json:"expired" help:"Tasks which ran for longer than the queue's ttl"`
Failed uint64 `json:"failed" help:"Tasks which failed with no retries left"`
Done uint64 `json:"done" help:"Tasks which are done"`
}
QueueWithStatus is a queue with the number of its tasks with each status
func (QueueWithStatus) Header ¶ added in v1.4.3
func (q QueueWithStatus) Header() []string
func (QueueWithStatus) String ¶ added in v1.4.3
func (q QueueWithStatus) String() string
func (QueueWithStatus) Width ¶ added in v1.4.3
func (q QueueWithStatus) Width(col int) int
type Task ¶
type Task struct {
Id uint64 `json:"id,omitempty"`
Queue string `json:"queue,omitempty"`
Worker *string `json:"worker,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
TaskMeta
CreatedAt *time.Time `json:"created_at,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
DiesAt *time.Time `json:"dies_at,omitempty"`
Retries *uint64 `json:"retries,omitempty"`
}
func TaskFromContext ¶ added in v1.4.0
TaskFromContext returns the task in the context of a queue's task callback, or nil if there isn't one
type TaskList ¶
type TaskList struct {
TaskListRequest
Count uint64 `json:"count"`
Body []TaskWithStatus `json:"body,omitempty"`
}
type TaskListRequest ¶
type TaskListRequest struct {
pg.OffsetLimit
Queue []string `json:"queue,omitempty" help:"Returns only the tasks in these queues, or in any queue" optional:""`
Status string `` /* 127-byte string literal not displayed */
}
func (TaskListRequest) Query ¶ added in v1.4.0
func (t TaskListRequest) Query() url.Values
Query returns the request as URL query parameters
type TaskMeta ¶
type TaskMeta struct {
Payload json.RawMessage `json:"payload,omitempty"`
DelayedAt *time.Time `json:"delayed_at,omitempty"`
}
type TaskRelease ¶
type TaskRelease struct {
Id uint64 `json:"id,omitempty"`
Fail bool `json:"fail,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
type TaskRetain ¶
type TaskWithStatus ¶
func (TaskWithStatus) Header ¶ added in v1.4.0
func (t TaskWithStatus) Header() []string
func (TaskWithStatus) String ¶
func (t TaskWithStatus) String() string
func (TaskWithStatus) Width ¶ added in v1.4.0
func (t TaskWithStatus) Width(col int) int
type Ticker ¶
type Ticker struct {
Ticker string `json:"ticker" arg:"" help:"Ticker name"`
TickerMeta
LastAt *time.Time `json:"last_at,omitempty"`
}
func TickerFromContext ¶ added in v1.4.0
TickerFromContext returns the ticker in the context of a ticker's callback, or nil if there isn't one
type TickerList ¶
type TickerList struct {
TickerListRequest
Count uint64 `json:"count"`
Body []Ticker `json:"body,omitempty"`
}
func (TickerList) String ¶
func (t TickerList) String() string
type TickerListRequest ¶
type TickerListRequest struct {
pg.OffsetLimit
}
func (TickerListRequest) Query ¶ added in v1.4.0
func (t TickerListRequest) Query() url.Values
Query returns the request as URL query parameters
func (TickerListRequest) String ¶
func (t TickerListRequest) String() string
type TickerMeta ¶
type TickerMeta struct {
Payload json.RawMessage `json:"payload,omitempty"`
Interval *time.Duration `json:"interval,omitempty" help:"Interval (default 1 minute)"`
}
func (TickerMeta) String ¶
func (t TickerMeta) String() string
type TickerName ¶
type TickerName string
func (TickerName) Validate ¶
func (t TickerName) Validate() (string, error)
type TickerNext ¶
type TickerNext struct {
Tickers []string `json:"tickers,omitempty"`
}
TickerNext gets the next due ticker of the tickers with the names
func (TickerNext) String ¶
func (t TickerNext) String() string