fix: InvalidClientTokenId panic + VT defaults + Dockerfile config + hardcore tests (58/61)
- Add InvalidClientTokenId, ValidationError to SqsErrors (was causing panic: WriteHeader code 0) - Extract applyEnvironmentDefaults() with defer in LoadYamlConfig (VT=30 even without config file) - Dockerfile: copy goaws.yaml to /conf/, pass --config flag - Fix SendMessageBatch form parsing for AWS Query Protocol - Add hardcore_test.sh (61 tests, 14 groups) - Remove temp debug logs from delete_message.go
This commit is contained in:
@@ -23,6 +23,9 @@ var envs map[string]models.Environment
|
||||
func LoadYamlConfig(filename string, env string) []string {
|
||||
ports := []string{"4100"}
|
||||
|
||||
// Гарантируем что дефолты всегда применяются, даже если конфиг не найден
|
||||
defer applyEnvironmentDefaults()
|
||||
|
||||
if filename == "" {
|
||||
root, _ := filepath.Abs(".")
|
||||
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
|
||||
@@ -77,30 +80,7 @@ models.LogFile = envs[env].LogFile
|
||||
}
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout = 30
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.MaximumMessageSize <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.MaximumMessageSize = 262144 // 256K
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.MessageRetentionPeriod <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.MessageRetentionPeriod = 345600 // 4 days
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.ReceiveMessageWaitTimeSeconds <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.ReceiveMessageWaitTimeSeconds = 0
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.AccountID == "" {
|
||||
models.CurrentEnvironment.AccountID = "queue"
|
||||
}
|
||||
|
||||
if models.CurrentEnvironment.Host == "" {
|
||||
models.CurrentEnvironment.Host = "localhost"
|
||||
models.CurrentEnvironment.Port = "4100"
|
||||
}
|
||||
// Дефолты применяются через defer applyEnvironmentDefaults() в начале функции
|
||||
|
||||
models.SyncQueues.Lock()
|
||||
for _, queue := range envs[env].Queues {
|
||||
@@ -156,6 +136,28 @@ models.SyncQueues.Unlock()
|
||||
return ports
|
||||
}
|
||||
|
||||
// applyEnvironmentDefaults — применяет дефолтные значения для QueueAttributeDefaults,
|
||||
// AccountID и Host. Вызывается через defer в LoadYamlConfig, чтобы дефолты
|
||||
// устанавливались при любом раннем return (например, если конфиг не найден).
|
||||
func applyEnvironmentDefaults() {
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout = 30
|
||||
}
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.MaximumMessageSize <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.MaximumMessageSize = 262144 // 256K
|
||||
}
|
||||
if models.CurrentEnvironment.QueueAttributeDefaults.MessageRetentionPeriod <= 0 {
|
||||
models.CurrentEnvironment.QueueAttributeDefaults.MessageRetentionPeriod = 345600 // 4 days
|
||||
}
|
||||
if models.CurrentEnvironment.AccountID == "" {
|
||||
models.CurrentEnvironment.AccountID = "queue"
|
||||
}
|
||||
if models.CurrentEnvironment.Host == "" {
|
||||
models.CurrentEnvironment.Host = "localhost"
|
||||
models.CurrentEnvironment.Port = "4100"
|
||||
}
|
||||
}
|
||||
|
||||
func setQueueRedrivePolicy(queues map[string]*models.Queue, q *models.Queue, strRedrivePolicy string) error {
|
||||
// Поддерживаем maxReceiveCount как int и как string (AWS SDK использует string)
|
||||
redrivePolicy1 := struct {
|
||||
|
||||
Reference in New Issue
Block a user