Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ func (m *Message) Encode() []byte {
return b
}

// Rest for reset default value
func (m *Message) Rest() {
m.Task = nil
m.Payload = nil
m.RetryCount = 0
m.Timeout = 0
m.RetryDelay = 0
}

func NewMessage(m core.QueuedMessage, opts ...AllowOption) *Message {
o := NewOptions(opts...)

Expand Down
7 changes: 4 additions & 3 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ func (q *Queue) Queue(m core.QueuedMessage, opts ...job.AllowOption) error {
}

message := job.NewMessage(m, opts...)
payload := message.Encode()
message.Rest()
message.Payload = payload

if err := q.worker.Queue(&job.Message{
Payload: message.Encode(),
}); err != nil {
if err := q.worker.Queue(message); err != nil {
return err
}

Expand Down