outbox for gateways
This commit is contained in:
33
api/gateway/common/outbox/model.go
Normal file
33
api/gateway/common/outbox/model.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package outbox
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/storable"
|
||||
)
|
||||
|
||||
const Collection = "outbox"
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusPending Status = "pending"
|
||||
StatusSent Status = "sent"
|
||||
StatusFailed Status = "failed"
|
||||
)
|
||||
|
||||
// Event represents an outbox message pending dispatch to the broker.
|
||||
type Event struct {
|
||||
storable.Base `bson:",inline" json:",inline"`
|
||||
|
||||
EventID string `bson:"eventId" json:"eventId"`
|
||||
Subject string `bson:"subject" json:"subject"`
|
||||
Payload []byte `bson:"payload" json:"payload"`
|
||||
Status Status `bson:"status" json:"status"`
|
||||
Attempts int `bson:"attempts" json:"attempts"`
|
||||
SentAt *time.Time `bson:"sentAt,omitempty" json:"sentAt,omitempty"`
|
||||
}
|
||||
|
||||
func (*Event) Collection() string {
|
||||
return Collection
|
||||
}
|
||||
Reference in New Issue
Block a user