28 lines
1.0 KiB
Go
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
|
|
}
|