forked from mtusi2026/mtusi2026lab5
116 lines
2.2 KiB
Go
116 lines
2.2 KiB
Go
package outbox
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type CreateMessageReq struct {
|
|
ID uuid.UUID
|
|
CreatedAt time.Time
|
|
Transport Transport
|
|
AggregateType string
|
|
AggregateID uuid.UUID
|
|
MessageType string
|
|
IdempotencyKey *string
|
|
SchemaVersion int
|
|
CausationID *uuid.UUID
|
|
Metadata map[string]string
|
|
Payload []byte
|
|
MaxAttempts int
|
|
Status Status
|
|
}
|
|
|
|
type CreateMessageRes struct {
|
|
ID uuid.UUID
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type MarkPublishedMessageReq struct {
|
|
ID uuid.UUID
|
|
UpdatedAt time.Time
|
|
PublishedAt time.Time
|
|
}
|
|
|
|
type MarkFailedMessageReq struct {
|
|
ID uuid.UUID
|
|
UpdatedAt time.Time
|
|
NextAttemptAt time.Time
|
|
LastError string
|
|
}
|
|
|
|
type MarkDeadLetterMessageReq struct {
|
|
ID uuid.UUID
|
|
UpdatedAt time.Time
|
|
DeadLetterAt time.Time
|
|
LastError string
|
|
}
|
|
|
|
type AcquireMessagesForProcessingReq struct {
|
|
Limit uint
|
|
LockDuration time.Duration
|
|
}
|
|
|
|
type AcquiredMessage struct {
|
|
Token uuid.UUID
|
|
ID uuid.UUID
|
|
Transport Transport
|
|
AggregateType string
|
|
AggregateID uuid.UUID
|
|
MessageType string
|
|
SchemaVersion int
|
|
CorrelationID uuid.UUID
|
|
CausationID *uuid.UUID
|
|
Status Status
|
|
Metadata map[string]string
|
|
Payload []byte
|
|
Attempts int
|
|
MaxAttempts int
|
|
LastError *string
|
|
LockedAt *time.Time
|
|
LockedUntil *time.Time
|
|
NextAttemptAt *time.Time
|
|
PublishedAt *time.Time
|
|
DeadLetterAt *time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt *time.Time
|
|
}
|
|
|
|
type RecoverStuckMessagesAsFailedReq struct {
|
|
UpdatedAt time.Time
|
|
NextAttemptAt time.Time
|
|
LastError string
|
|
Limit uint
|
|
}
|
|
|
|
type RecoverStuckMessagesAsDeadLetterReq struct {
|
|
UpdatedAt time.Time
|
|
DeadLetterAt time.Time
|
|
LastError string
|
|
Limit uint
|
|
}
|
|
|
|
type DeliveryMessage struct {
|
|
ID uuid.UUID
|
|
Transport Transport
|
|
AggregateType string
|
|
AggregateID uuid.UUID
|
|
MessageType string
|
|
SchemaVersion int
|
|
CorrelationID uuid.UUID
|
|
CausationID *uuid.UUID
|
|
Payload []byte
|
|
Metadata map[string]string
|
|
}
|
|
|
|
type ProcessOnceResult struct {
|
|
RecoveredAsFailed int64
|
|
RecoveredAsDeadLetter int64
|
|
|
|
Acquired int
|
|
Published int
|
|
Failed int
|
|
DeadLettered int
|
|
}
|