feat(domain,db): lab5 add outbox entry, transaction contract and 0006 migration

This commit is contained in:
Голиков Maximillian Антон
2026-11-06 22:43:56 +03:00
parent 18afe2563e
commit 7f0fb2b0da
4 changed files with 82 additions and 0 deletions
+28
View File
@@ -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
}