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:
@@ -1,8 +1,10 @@
|
||||
package gosqs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
@@ -85,5 +87,24 @@ func setQueueAttributesV1(q *models.Queue, attr models.QueueAttributes, provided
|
||||
q.DeadLetterQueue = deadLetterQueue
|
||||
q.MaxReceiveCount = attr.RedrivePolicy.MaxReceiveCount.Int()
|
||||
}
|
||||
|
||||
// Шаг 4: FIFO-атрибуты и Policy — храним как есть (совместимость с Terraform).
|
||||
// FifoQueue только включаем (выключить FIFO у существующей очереди нельзя —
|
||||
// как и в AWS). ContentBasedDeduplication и Policy не исполняются,
|
||||
// но должны возвращаться в GetQueueAttributes, иначе drift в Terraform.
|
||||
if attr.FifoQueue.Bool() {
|
||||
q.IsFIFO = true
|
||||
}
|
||||
if attr.ContentBasedDeduplication.Bool() {
|
||||
q.ContentBasedDeduplication = true
|
||||
}
|
||||
if attr.Policy != nil {
|
||||
// Сохраняем канонический JSON (map → marshal сортирует ключи) —
|
||||
// детерминированно, без drift при чтении.
|
||||
if data, err := json.Marshal(attr.Policy); err == nil {
|
||||
q.Policy = string(data)
|
||||
}
|
||||
}
|
||||
q.LastModifiedAt = time.Now().UTC()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user