feat(aws-compat): queue attributes for Terraform (FifoQueue, ContentBasedDeduplication, Policy, real timestamps)
- GetQueueAttributes now returns FifoQueue, ContentBasedDeduplication, Policy and real Created/LastModifiedTimestamp (previously missing/stubbed '0000000000') - Queue: add CreatedAt, LastModifiedAt, Policy, ContentBasedDeduplication - parse FifoQueue/ContentBasedDeduplication in both protocols (StringToBool) - Policy/RedriveAllowPolicy: normalize JSON-string form to object (JSON protocol sent them as string -> SetQueueAttributes failed with InvalidParameterValue) - persistence: keep new fields in meta DTO + backfill empty timestamps on load - FIFO dedup is inherent: IsDuplicate/InitDuplicatation gate on IsFIFO only (env flag EnableDuplicates=false disabled dedup for all FIFO queues)
This commit is contained in:
@@ -167,6 +167,11 @@ type queueMetaDTO struct {
|
||||
Tags map[string]string
|
||||
LastPurgeTime time.Time
|
||||
DeadLetterQueueName string `json:"dead_letter_queue_name,omitempty"`
|
||||
// Создание/изменение + совместимые атрибуты (GetQueueAttributes/Terraform).
|
||||
CreatedAt time.Time
|
||||
LastModifiedAt time.Time
|
||||
Policy string
|
||||
ContentBasedDeduplication bool
|
||||
}
|
||||
|
||||
// queueToMetaDTO — строит снимок очереди без сообщений, НЕ мутируя исходную очередь.
|
||||
@@ -194,6 +199,10 @@ func queueToMetaDTO(q *models.Queue) *queueMetaDTO {
|
||||
Tags: q.Tags,
|
||||
LastPurgeTime: q.LastPurgeTime,
|
||||
DeadLetterQueueName: q.DeadLetterQueueName,
|
||||
CreatedAt: q.CreatedAt,
|
||||
LastModifiedAt: q.LastModifiedAt,
|
||||
Policy: q.Policy,
|
||||
ContentBasedDeduplication: q.ContentBasedDeduplication,
|
||||
}
|
||||
if q.DeadLetterQueue != nil {
|
||||
dto.DeadLetterQueueName = q.DeadLetterQueue.Name
|
||||
@@ -452,6 +461,16 @@ func LoadAllQueues() (map[string]*models.Queue, error) {
|
||||
q.FIFOSequenceNumbers = make(map[string]int)
|
||||
}
|
||||
|
||||
// Бэкфилл timestamp-ов: у очередей, созданных до появления полей, они нулевые.
|
||||
// Без этого Terraform видел бы CreatedTimestamp=0 и постоянный drift.
|
||||
// Заполняем сейчас и сохраним при ближайшем SaveQueue.
|
||||
if q.CreatedAt.IsZero() {
|
||||
q.CreatedAt = time.Now().UTC()
|
||||
}
|
||||
if q.LastModifiedAt.IsZero() {
|
||||
q.LastModifiedAt = q.CreatedAt
|
||||
}
|
||||
|
||||
// Миграция v1→v2: если в JSON есть Messages — это старый формат
|
||||
if len(q.Messages) > 0 {
|
||||
migrateKeys = append(migrateKeys, k)
|
||||
|
||||
Reference in New Issue
Block a user