service backend
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful

This commit is contained in:
Stephan D
2025-11-07 18:35:26 +01:00
parent 20e8f9acc4
commit 62a6631b9a
537 changed files with 48453 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package model
import (
"time"
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/model"
)
// OutboxEvent represents a pending event to be published to NATS.
// Part of the transactional outbox pattern for reliable event delivery.
type OutboxEvent struct {
storable.Base `bson:",inline" json:",inline"`
model.OrganizationBoundBase `bson:",inline" json:",inline"`
EventID string `bson:"eventId" json:"eventId"` // deterministic ID for NATS Msg-Id deduplication
Subject string `bson:"subject" json:"subject"` // NATS subject to publish to
Payload []byte `bson:"payload" json:"payload"` // JSON-encoded event data
Status OutboxStatus `bson:"status" json:"status"` // pending, sent, failed
Attempts int `bson:"attempts" json:"attempts"` // number of delivery attempts
SentAt *time.Time `bson:"sentAt,omitempty" json:"sentAt,omitempty"`
}
// Collection implements storable.Storable.
func (*OutboxEvent) Collection() string {
return OutboxCollection
}