2020-01-03 10:13:16 +08:00
|
|
|
// Copyright 2020 Kentaro Hibino. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
2019-11-15 13:07:19 +08:00
|
|
|
package asynq
|
|
|
|
|
2019-11-17 06:45:51 +08:00
|
|
|
/*
|
|
|
|
TODOs:
|
2020-01-03 10:13:16 +08:00
|
|
|
- [P0] Go docs
|
2019-11-17 06:45:51 +08:00
|
|
|
*/
|
|
|
|
|
2019-11-15 13:07:19 +08:00
|
|
|
// Task represents a task to be performed.
|
|
|
|
type Task struct {
|
2020-01-05 05:13:46 +08:00
|
|
|
// Type indicates the type of task to be performed.
|
2019-11-17 06:45:51 +08:00
|
|
|
Type string
|
|
|
|
|
2019-12-28 12:37:15 +08:00
|
|
|
// Payload holds data needed to process the task.
|
2019-12-19 23:13:43 +08:00
|
|
|
Payload Payload
|
2019-11-15 13:07:19 +08:00
|
|
|
}
|
2020-01-05 05:13:46 +08:00
|
|
|
|
|
|
|
// NewTask returns a new instance of a task given a task type and payload.
|
|
|
|
//
|
|
|
|
// Since payload data gets serialized to JSON, the payload values must be
|
|
|
|
// composed of JSON supported data types.
|
|
|
|
func NewTask(typename string, payload map[string]interface{}) *Task {
|
|
|
|
return &Task{
|
|
|
|
Type: typename,
|
|
|
|
Payload: Payload{payload},
|
|
|
|
}
|
|
|
|
}
|