service backend
This commit is contained in:
27
api/ledger/storage/model/outbox.go
Normal file
27
api/ledger/storage/model/outbox.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user