Skip to content

Commit

Permalink
Allow for queue specific visibility time out setting
Browse files Browse the repository at this point in the history
  • Loading branch information
qhenkart authored and Admiral-Piett committed Nov 22, 2023
1 parent 9aafff9 commit 42f5c2d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ type EnvQueue struct {
ReceiveMessageWaitTimeSeconds int
RedrivePolicy string
MaximumMessageSize int
VisibilityTimeout int
}

type EnvQueueAttributes struct {
VisibilityTimeout int
ReceiveMessageWaitTimeSeconds int
MaximumMessageSize int
MaximumMessageSize int
}

type Environment struct {
Expand All @@ -41,7 +42,7 @@ type Environment struct {
Topics []EnvTopic
Queues []EnvQueue
QueueAttributeDefaults EnvQueueAttributes
RandomLatency RandomLatency
RandomLatency RandomLatency
}

var CurrentEnvironment Environment
Expand Down
7 changes: 6 additions & 1 deletion app/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,18 @@ func LoadYamlConfig(filename string, env string) []string {
if queue.ReceiveMessageWaitTimeSeconds == 0 {
queue.ReceiveMessageWaitTimeSeconds = app.CurrentEnvironment.QueueAttributeDefaults.ReceiveMessageWaitTimeSeconds
}

if queue.MaximumMessageSize == 0 {
queue.MaximumMessageSize = app.CurrentEnvironment.QueueAttributeDefaults.MaximumMessageSize
}

if queue.VisibilityTimeout == 0 {
queue.VisibilityTimeout = app.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout
}

app.SyncQueues.Queues[queue.Name] = &app.Queue{
Name: queue.Name,
TimeoutSecs: app.CurrentEnvironment.QueueAttributeDefaults.VisibilityTimeout,
TimeoutSecs: queue.VisibilityTimeout,
Arn: queueArn,
URL: queueUrl,
ReceiveWaitTimeSecs: queue.ReceiveMessageWaitTimeSeconds,
Expand Down
7 changes: 6 additions & 1 deletion app/conf/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ func TestConfig_QueueAttributes(t *testing.T) {
}
maximumMessageSize = app.SyncQueues.Queues["local-queue2"].MaximumMessageSize
if maximumMessageSize != 128 {
t.Errorf("Expected local-queue1 Queue to be configured with MaximumMessageSize: 128 but got %d\n", maximumMessageSize)
t.Errorf("Expected local-queue2 Queue to be configured with MaximumMessageSize: 128 but got %d\n", maximumMessageSize)
}

timeoutSecs = app.SyncQueues.Queues["local-queue2"].TimeoutSecs
if timeoutSecs != 150 {
t.Errorf("Expected local-queue2 Queue to be configured with VisibilityTimeout: 150 but got %d\n", timeoutSecs)
}
}

Expand Down
1 change: 1 addition & 0 deletions app/conf/mock-data/mock-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Local: # Environment name that can be passed on the
- Name: local-queue2 # Queue name
ReceiveMessageWaitTimeSeconds: 20 # Queue receive message max wait time
MaximumMessageSize: 128 # Queue maximum message size (bytes)
VisibilityTimeout: 150 # Queue visibility timeout
- Name: local-queue3 # Queue name
RedrivePolicy: '{"maxReceiveCount": 100, "deadLetterTargetArn":"arn:aws:sqs:us-east-1:000000000000:local-queue3-dlq"}'
- Name: local-queue3-dlq # Queue name
Expand Down

0 comments on commit 42f5c2d

Please sign in to comment.