mirror of
https://github.com/hibiken/asynq.git
synced 2026-08-17 01:13:41 +08:00
Feature: Add Headers Support to Tasks (#1070)
* feat(task): Add headers support to tasks * fix: cleanup copy map code * fix: Add tests
This commit is contained in:
@@ -240,6 +240,9 @@ type TaskMessage struct {
|
||||
// Payload holds data needed to process the task.
|
||||
Payload []byte
|
||||
|
||||
// Headers holds additional metadata for the task.
|
||||
Headers map[string]string
|
||||
|
||||
// ID is a unique identifier for each task.
|
||||
ID string
|
||||
|
||||
@@ -304,6 +307,7 @@ func EncodeMessage(msg *TaskMessage) ([]byte, error) {
|
||||
return proto.Marshal(&pb.TaskMessage{
|
||||
Type: msg.Type,
|
||||
Payload: msg.Payload,
|
||||
Headers: msg.Headers,
|
||||
Id: msg.ID,
|
||||
Queue: msg.Queue,
|
||||
Retry: int32(msg.Retry),
|
||||
@@ -328,6 +332,7 @@ func DecodeMessage(data []byte) (*TaskMessage, error) {
|
||||
return &TaskMessage{
|
||||
Type: pbmsg.GetType(),
|
||||
Payload: pbmsg.GetPayload(),
|
||||
Headers: pbmsg.GetHeaders(),
|
||||
ID: pbmsg.GetId(),
|
||||
Queue: pbmsg.GetQueue(),
|
||||
Retry: int(pbmsg.GetRetry()),
|
||||
|
||||
Reference in New Issue
Block a user