Files
sendico/api/ledger/storage/model/outbox.go
Stephan D 62a6631b9a
All checks were successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
service backend
2025-11-07 18:35:26 +01:00

28 lines
1.0 KiB
Go

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
}