feat(domain,db): lab5 add outbox entry, transaction contract and 0006 migration
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
OutboxAggregateAttachment = "attachment"
|
||||
OutboxEventProcess = "attachment.process"
|
||||
)
|
||||
|
||||
// OutboxEntry — намерение опубликовать сообщение, записанное
|
||||
// в одной транзакции с бизнес-изменением (transactional outbox).
|
||||
//
|
||||
// Инварианты:
|
||||
// - PublishedAt == nil => ещё не опубликовано, publisher обязан дослать;
|
||||
// - PublishedAt != nil => RabbitMQ принял сообщение,
|
||||
// а не «мы вызвали Publish». At-least-once: повторная доставка
|
||||
// возможна и нормальна, гасится идемпотентностью consumer'а.
|
||||
//
|
||||
type OutboxEntry struct {
|
||||
ID string
|
||||
AggregateType string
|
||||
AggregateID string
|
||||
EventType string
|
||||
Payload []byte
|
||||
CreatedAt time.Time
|
||||
PublishedAt *time.Time
|
||||
Attempts int
|
||||
}
|
||||
Reference in New Issue
Block a user