snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

45
tools/pq/cli/message.go Normal file
View File

@@ -0,0 +1,45 @@
package cli
import (
"time"
"github.com/ThreeDotsLabs/watermill/components/delay"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
)
type Message struct {
// ID is a unique message ID across the Pub/Sub's topic.
ID string
UUID string
Payload string
Metadata map[string]string
OriginalTopic string
DelayedUntil string
DelayedFor string
RequeueIn time.Duration
}
func NewMessage(id string, uuid string, payload string, metadata map[string]string) (Message, error) {
originalTopic := metadata[middleware.PoisonedTopicKey]
// Calculate the time until the message should be requeued
delayedUntil, err := time.Parse(time.RFC3339, metadata[delay.DelayedUntilKey])
if err != nil {
return Message{}, err
}
delayedFor := metadata[delay.DelayedForKey]
requeueIn := delayedUntil.Sub(time.Now().UTC()).Round(time.Second)
return Message{
ID: id,
UUID: uuid,
Payload: payload,
Metadata: metadata,
OriginalTopic: originalTopic,
DelayedUntil: delayedUntil.String(),
DelayedFor: delayedFor,
RequeueIn: requeueIn,
}, nil
}