2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-22 09:56:12 +08:00

Change payload to byte slice

This commit is contained in:
Ken Hibino
2021-03-20 13:42:13 -07:00
parent a0b52806c9
commit dc275c4612
21 changed files with 254 additions and 1156 deletions

View File

@@ -17,20 +17,21 @@ import (
// Task represents a unit of work to be performed.
type Task struct {
// Type indicates the type of task to be performed.
Type string
// typename indicates the type of task to be performed.
typename string
// Payload holds data needed to perform the task.
Payload Payload
// payload holds data needed to perform the task.
payload []byte
}
func (t *Task) Type() string { return t.typename }
func (t *Task) Payload() []byte { return t.payload }
// NewTask returns a new Task given a type name and payload data.
//
// The payload values must be serializable.
func NewTask(typename string, payload map[string]interface{}) *Task {
func NewTask(typename string, payload []byte) *Task {
return &Task{
Type: typename,
Payload: Payload{payload},
typename: typename,
payload: payload,
}
}