redisqueue

package
v0.0.0-...-122f59b Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTaskNotFound = apierrors.NotFound.WithReason("TaskNotFound").New("task not found")
View Source
var QueueUserImport = "user-import"
View Source
var QueueUserReindex = "user-reindex"
View Source
var TTL = 24 * time.Hour

Functions

func RedisKeyForQueue

func RedisKeyForQueue(queueName string) string

func RedisKeyForTask

func RedisKeyForTask(appID string, taskID string) string

Types

type Producer

type Producer struct {
	QueueName string
	Redis     *appredis.Handle
	Clock     clock.Clock
}

func (*Producer) EnqueueTask

func (p *Producer) EnqueueTask(ctx context.Context, task *Task) error

func (*Producer) GetTask

func (p *Producer) GetTask(ctx context.Context, item *QueueItem) (*Task, error)

func (*Producer) NewTask

func (p *Producer) NewTask(appID string, input json.RawMessage) *Task

type QueueItem

type QueueItem struct {
	AppID  string `json:"app_id,omitempty"`
	TaskID string `json:"task_id,omitempty"`
}

func (*QueueItem) RedisKey

func (i *QueueItem) RedisKey() string

type Task

type Task struct {
	ID          string          `json:"id,omitempty"`
	AppID       string          `json:"app_id,omitempty"`
	CreatedAt   *time.Time      `json:"created_at,omitempty"`
	CompletedAt *time.Time      `json:"completed_at,omitempty"`
	Status      TaskStatus      `json:"status,omitempty"`
	Input       json.RawMessage `json:"input,omitempty"`
	Output      json.RawMessage `json:"output,omitempty"`
}

func (*Task) RedisKey

func (t *Task) RedisKey() string

func (*Task) ToQueueItem

func (t *Task) ToQueueItem() *QueueItem

type TaskStatus

type TaskStatus string
const (
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusCompleted TaskStatus = "completed"
)

type UserImportProducer

type UserImportProducer struct {
	*Producer
}

func NewUserImportProducer

func NewUserImportProducer(redis *appredis.Handle, clock clock.Clock) *UserImportProducer

type UserReindexProducer

type UserReindexProducer struct {
	*Producer
}

func NewUserReindexProducer

func NewUserReindexProducer(redis *appredis.Handle, clock clock.Clock) *UserReindexProducer

Jump to

Keyboard shortcuts

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