job

package
v0.0.0-...-0ede13a Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID    string
	Queue string

	Context context.Context
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, id string, queue string, runnable Runnable, storage Storage, purge bool) *Job

func (*Job) Custom

func (s *Job) Custom(name string, body string) *Job

func (*Job) Done

func (s *Job) Done() *Job

func (*Job) DoneWithMessage

func (s *Job) DoneWithMessage(msg string) *Job

func (*Job) Download

func (s *Job) Download(url string) *Job

func (*Job) Error

func (s *Job) Error(err error) error

func (*Job) InProgress

func (s *Job) InProgress(message string) *Job

func (*Job) Info

func (s *Job) Info(message string) *Job

func (*Job) ObserveLog

func (s *Job) ObserveLog() *Observer

func (*Job) Redirect

func (s *Job) Redirect(url string) *Job

func (*Job) RenderTemplate

func (s *Job) RenderTemplate(name string, body string) *Job

func (*Job) Run

func (s *Job) Run(ctx context.Context) error

func (*Job) StatusUpdate

func (s *Job) StatusUpdate(status string) *Job

func (*Job) Warn

func (s *Job) Warn(err error, message string) *Job

type Jobs

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

func (*Jobs) Enqueue

func (s *Jobs) Enqueue(ctx context.Context, cancel context.CancelFunc, id string, r Runnable, purge bool) *Job

func (*Jobs) Log

func (s *Jobs) Log(ctx context.Context, id string) (c chan LogItem, ok bool, err error)

type LogItem

type LogItem struct {
	Level     LogItemLevel `json:"level,omitempty"`
	Message   string       `json:"message,omitempty"`
	Status    string       `json:"status,omitempty"`
	Tag       string       `json:"tag,omitempty"`
	Location  string       `json:"location,omitempty"`
	Template  string       `json:"template,omitempty"`
	Body      string       `json:"body,omitempty"`
	Timestamp time.Time    `json:"timestamp,omitempty"`
}

type LogItemLevel

type LogItemLevel string
const (
	Info           LogItemLevel = "info"
	Error          LogItemLevel = "error"
	Warn           LogItemLevel = "warn"
	Done           LogItemLevel = "done"
	InProgress     LogItemLevel = "inprogress"
	Redirect       LogItemLevel = "redirect"
	Download       LogItemLevel = "download"
	RenderTemplate LogItemLevel = "rendertemplate"
	Custom         LogItemLevel = "custom"
	StatusUpdate   LogItemLevel = "statusupdate"
	Close          LogItemLevel = "close"
	Open           LogItemLevel = "open"
)

type NilStorage

type NilStorage struct{}

func (*NilStorage) Drop

func (s *NilStorage) Drop(_ context.Context, _ string) (err error)

func (*NilStorage) GetState

func (s *NilStorage) GetState(_ context.Context, _ string) (state *State, ok bool, err error)

func (*NilStorage) Pub

func (s *NilStorage) Pub(_ context.Context, _ string, _ LogItem) error

func (*NilStorage) Sub

func (s *NilStorage) Sub(_ context.Context, _ string) (res chan LogItem, err error)

type Observer

type Observer struct {
	C  chan LogItem
	ID string
	// contains filtered or unexported fields
}

func NewObserver

func NewObserver() *Observer

func (*Observer) Close

func (s *Observer) Close()

func (*Observer) Push

func (s *Observer) Push(ctx context.Context, v LogItem)

type Queues

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

func NewQueues

func NewQueues(storage Storage) *Queues

func (Queues) GetOrCreate

func (s Queues) GetOrCreate(name string) *Jobs

type Redis

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

func NewRedis

func NewRedis(cl redis.UniversalClient, prefix string) *Redis

func (*Redis) Drop

func (s *Redis) Drop(ctx context.Context, id string) (err error)

func (*Redis) GetState

func (s *Redis) GetState(ctx context.Context, id string) (state *State, ok bool, err error)

func (*Redis) Pub

func (s *Redis) Pub(ctx context.Context, id string, l LogItem) (err error)

func (*Redis) Sub

func (s *Redis) Sub(ctx context.Context, id string) (res chan LogItem, err error)

type Runnable

type Runnable interface {
	Run(j *Job) error
}

type Script

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

func NewScript

func NewScript(body func(j *Job) error) *Script

func (*Script) Run

func (s *Script) Run(j *Job) error

type State

type State struct {
	ID  string
	TTL time.Duration
}

type Storage

type Storage interface {
	Pub(ctx context.Context, id string, l LogItem) error
	Sub(ctx context.Context, id string) (res chan LogItem, err error)
	GetState(ctx context.Context, id string) (state *State, ok bool, err error)
	Drop(ctx context.Context, id string) (err error)
}

func NewStorage

func NewStorage(rc *cs.RedisClient, prefix string) Storage

Jump to

Keyboard shortcuts

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