Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SNS SubscribeV1 for new pattern support #308

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/cmd/goaws.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"os"
"time"

"github.com/Admiral-Piett/goaws/app/utils"

"github.com/Admiral-Piett/goaws/app"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -63,8 +61,6 @@ func main() {
quit := make(chan struct{}, 0)
go gosqs.PeriodicTasks(1*time.Second, quit)

utils.InitializeDecoders()

if len(portNumbers) == 1 {
log.Warnf("GoAws listening on: 0.0.0.0:%s", portNumbers[0])
err := http.ListenAndServe("0.0.0.0:"+portNumbers[0], r)
Expand Down
1 change: 1 addition & 0 deletions app/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
var LogMessages bool
var LogFile string

// TODO - Admiral-Piett replace with `github.com/google/uuid` - `uuid.NewString()`
func NewUUID() (string, error) {
uuid := make([]byte, 16)
n, err := io.ReadFull(rand.Reader, uuid)
Expand Down
7 changes: 7 additions & 0 deletions app/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ func LoadYamlConfig(filename string, env string) []string {
return ports
}
}

filename, _ = filepath.Abs(filename)
if _, err := os.Stat(filename); err != nil {
log.Warnf("Failure to find config file: %s", filename)
return ports
}

log.Infof("Loading config file: %s", filename)
yamlFile, err := os.ReadFile(filename)
if err != nil {
Expand Down
18 changes: 17 additions & 1 deletion app/conf/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestConfig_QueueAttributes(t *testing.T) {
assert.Equal(t, 1024, app.SyncQueues.Queues["local-queue1"].MaximumMessageSize)
assert.Equal(t, emptyQueue, app.SyncQueues.Queues["local-queue1"].DeadLetterQueue)
assert.Equal(t, 0, app.SyncQueues.Queues["local-queue1"].MaxReceiveCount)
assert.Equal(t, 445600, app.SyncQueues.Queues["local-queue1"].MessageRetentionPeriod)
assert.Equal(t, 345600, app.SyncQueues.Queues["local-queue1"].MessageRetentionPeriod)
assert.Equal(t, 100, app.SyncQueues.Queues["local-queue3"].MaxReceiveCount)

assert.Equal(t, "local-queue3-dlq", app.SyncQueues.Queues["local-queue3"].DeadLetterQueue.Name)
Expand Down Expand Up @@ -148,3 +148,19 @@ func TestConfig_LoadYamlConfig_finds_default_config(t *testing.T) {
assert.True(t, ok)
}
}

func TestConfig_LoadYamlConfig_missing_config_loads_nothing(t *testing.T) {
app.CurrentEnvironment = app.Environment{}
ports := LoadYamlConfig("/garbage", "Local")

assert.Equal(t, []string{"4100"}, ports)
assert.Equal(t, app.CurrentEnvironment, app.Environment{})
}

func TestConfig_LoadYamlConfig_invalid_config_loads_nothing(t *testing.T) {
app.CurrentEnvironment = app.Environment{}
ports := LoadYamlConfig("../common/common.go", "Local")

assert.Equal(t, []string{"4100"}, ports)
assert.Equal(t, app.CurrentEnvironment, app.Environment{})
}
1 change: 1 addition & 0 deletions app/conf/goaws.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
VisibilityTimeout: 30 # message visibility timeout
ReceiveMessageWaitTimeSeconds: 0 # receive message max wait time
MaximumMessageSize: 262144 # maximum message size (bytes)
# MessageRetentionPeriod: 445600 # time period to retain messages (seconds) NOTE: Functionality not implemented
Queues: # List of queues to create at startup
- Name: local-queue1 # Queue name
- Name: local-queue2 # Queue name
Expand Down
80 changes: 42 additions & 38 deletions app/conf/mock-data/mock-config.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it's a problem, but can you tell me why you deleted the comment?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because they're all already on the default one, /conf/goaws.yaml, and I got tired of having them all over the place. I figured one source of reference would be enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense! 👍

Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
Local: # Environment name that can be passed on the command line
# (i.e.: ./goaws [Local | Dev] -- defaults to 'Local')
Host: localhost # hostname of the goaws system (for docker-compose this is the tag name of the container)
Port: 4100 # port to listen on.
Local:
Host: localhost
Port: 4100
Region: us-east-1
AccountId: "100010001000"
LogMessages: true # Log messages (true/false)
LogFile: ./goaws_messages.log # Log filename (for message logging
QueueAttributeDefaults: # default attributes for all queues
VisibilityTimeout: 10 # message visibility timeout
ReceiveMessageWaitTimeSeconds: 10 # receive message max wait time
MaximumMessageSize: 1024 # maximum message size (bytes)
MessageRetentionPeriod: 445600 # time period to retain messages (seconds) NOTE: Functionality not implemented
Queues: # List of queues to create at startup
- Name: local-queue1 # Queue name
- 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
LogMessages: true
LogFile: ./goaws_messages.log
QueueAttributeDefaults:
VisibilityTimeout: 10
ReceiveMessageWaitTimeSeconds: 10
MaximumMessageSize: 1024
Queues:
- Name: local-queue1
- Name: local-queue2
ReceiveMessageWaitTimeSeconds: 20
MaximumMessageSize: 128
VisibilityTimeout: 150
MessageRetentionPeriod: 245600
- Name: local-queue3 # Queue name
- Name: local-queue3
RedrivePolicy: '{"maxReceiveCount": 100, "deadLetterTargetArn":"arn:aws:sqs:us-east-1:100010001000:local-queue3-dlq"}'
- Name: local-queue3-dlq # Queue name
Topics: # List of topic to create at startup
- Name: local-topic1 # Topic name - with some Subscriptions
Subscriptions: # List of Subscriptions to create for this topic (queues will be created as required)
- QueueName: local-queue4 # Queue name
Raw: false # Raw message delivery (true/false)
- QueueName: local-queue5 # Queue name
Raw: true # Raw message delivery (true/false)
FilterPolicy: '{"foo":["bar"]}' # Subscription's FilterPolicy, json like a string
- Name: local-topic2 # Topic name - no Subscriptions
- Name: local-queue3-dlq
Topics:
- Name: local-topic1
Subscriptions:
- QueueName: local-queue4
Raw: false
- QueueName: local-queue5
Raw: true
FilterPolicy: '{"foo":["bar"]}'
- Name: local-topic2

NoQueuesOrTopics: # Another environment
NoQueuesOrTopics:
Host: localhost
Port: 4100
LogMessages: true
Expand All @@ -50,15 +48,21 @@ NoQueueAttributeDefaults:
ReceiveMessageWaitTimeSeconds: 20

BaseUnitTests:
# (i.e.: ./goaws [Local | Dev] -- defaults to 'Local')
Host: host # hostname of the goaws system (for docker-compose this is the tag name of the container)
Port: port # port to listen on.
Host: host
Port: port
Region: region
AccountId: accountID
LogMessages: true # Log messages (true/false)
LogFile: ./goaws_messages.log # Log filename (for message logging
Queues: # List of queues to create at startup
- Name: unit-queue1 # Queue name
- Name: unit-queue2 # Queue name
LogMessages: true
LogFile: ./goaws_messages.log
Queues:
- Name: unit-queue1
- Name: unit-queue2
RedrivePolicy: '{"maxReceiveCount": 100, "deadLetterTargetArn":"arn:aws:sqs:us-east-1:100010001000:other-queue1"}'
- Name: other-queue1 # Queue name
- Name: other-queue1
- Name: subscribed-queue2
Topics:
- Name: unit-topic1
Subscriptions:
- QueueName: subscribed-queue2
Raw: true
- Name: unit-topic2
68 changes: 0 additions & 68 deletions app/examples/java/SnsSample.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to delete these examples. I guess they used to test compatibility with AWS SDK here. But we already have smoke tests 👍

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I think they were a throw to old automated smoke tests. I think we have our new pattern now which will work. If we want to incorporate more SDKs down the road we can - I think we can try to cross that bridge when we need it.

This file was deleted.

87 changes: 0 additions & 87 deletions app/examples/java/SqsSample.java

This file was deleted.

Loading
Loading