outbox for gateways

This commit is contained in:
Stephan D
2026-02-18 01:35:28 +01:00
parent 974caf286c
commit 69531cee73
221 changed files with 12172 additions and 782 deletions

View File

@@ -1,35 +0,0 @@
package ledger
import (
"time"
"github.com/tech/sendico/pkg/db/storable"
"github.com/tech/sendico/pkg/mservice"
)
// Delivery status enum
type OutboxStatus string
const (
OutboxPending OutboxStatus = "pending"
OutboxSent OutboxStatus = "sent"
OutboxFailed OutboxStatus = "failed" // terminal after max retries, or keep pending with NextAttemptAt=nil
)
type OutboxEvent struct {
storable.Base `bson:",inline" json:",inline"`
EventID string `bson:"eventId" json:"eventId"` // deterministic; use as NATS Msg-Id
Subject string `bson:"subject" json:"subject"` // NATS subject / stream routing key
Payload []byte `bson:"payload" json:"payload"` // JSON (or other) payload
Status OutboxStatus `bson:"status" json:"status"` // enum
Attempts int `bson:"attempts" json:"attempts"` // total tries
NextAttemptAt *time.Time `bson:"nextAttemptAt,omitempty" json:"nextAttemptAt,omitempty"` // for backoff scheduler
SentAt *time.Time `bson:"sentAt,omitempty" json:"sentAt,omitempty"`
LastError string `bson:"lastError,omitempty" json:"lastError,omitempty"` // brief reason of last failure
CorrelationRef string `bson:"correlationRef,omitempty" json:"correlationRef,omitempty"` // e.g., journalEntryRef or idempotencyKey
}
func (o *OutboxEvent) Collection() string {
return mservice.LedgerOutbox
}