taskq

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: GPL-3.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DbGet                = "dbGet"
	DbSet                = "dbSet"
	DbInsert             = "dbInsert"
	DbDelete             = "dbDelete"
	DbFind               = "dbFind"
	DbLoadRefs           = "dbLoadRefs"
	DbPush               = "dbPush"
	WidgetData           = "widgetData"
	Auth                 = "authentication"
	SignUp               = "signup"
	SignOut              = "signOut"
	DidSignOut           = "didSignOut"
	PasswordResetRequest = "passwordResetRequest"
	PasswordReset        = "passwordReset"
	UserConfig           = "userConfig"
	DbAction             = "action"
	HTTPHook             = "httpHook"
	ScheduledScript      = "scheduledScript"
	StoreLifeCycle       = "storeLifeCycle"
)

tasks decription constants

Variables

View Source
var (

	// ErrTimeout is a timeout error for tasks
	ErrTimeout = errors.New("timeout")
)

Functions

func Done

func Done(r Result)

Done must be called when task is done

func Push

func Push(t *Task) chan Result

Push ads new task to a queue with assigning new ID

func PushAndGetResult

func PushAndGetResult(t *Task, timeout time.Duration) (interface{}, error)

PushAndGetResult is the alternative way to push task. It returns result and error instead of channel. Second argument is a task timeout. If provided, when timeout reached and task will not completed yet, error returns with nil result

func UnShift

func UnShift(t *Task)

UnShift returns task to the queue

Types

type Result

type Result struct {
	ID     uint64
	Result interface{}
	Err    string
}

Result is a struct for result of task

type Task

type Task struct {
	ID        uint64                 `json:"id"`
	UserID    interface{}            `json:"userId"`
	Store     string                 `json:"store"`
	Type      string                 `json:"type"`
	Arguments map[string]interface{} `json:"args"`

	sync.Mutex
	// contains filtered or unexported fields
}

Task represents task for workers

func Shift

func Shift() (t *Task)

Shift returns task from the queue

Jump to

Keyboard shortcuts

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