mirror of
https://github.com/oarkflow/mq.git
synced 2025-09-27 20:32:15 +08:00
25 lines
623 B
Go
25 lines
623 B
Go
package mq
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type Task struct {
|
|
CreatedAt time.Time `json:"created_at"`
|
|
ProcessedAt time.Time `json:"processed_at"`
|
|
Expiry time.Time `json:"expiry"`
|
|
Error error `json:"error"`
|
|
ID string `json:"id"`
|
|
Topic string `json:"topic"`
|
|
Status string `json:"status"`
|
|
Payload json.RawMessage `json:"payload"`
|
|
}
|
|
|
|
func NewTask(id string, payload json.RawMessage, nodeKey string) *Task {
|
|
if id == "" {
|
|
id = NewID()
|
|
}
|
|
return &Task{ID: id, Payload: payload, Topic: nodeKey, CreatedAt: time.Now()}
|
|
}
|