GoAWS.jl wraps the go library goaws to provide a clone of Amazon Web Services (AWS) SQS and SNS services. This facilitates testing and development of code interacting with these services without needing to spin up and authenticate to cloud resources.
SQS stands for Simple Queue Service, and provides a simple and robust message queue. For example, it can be used as a work queue, where one pushes messages describing the work to be done onto the queue, and workers can poll the queue to retrieve assignments.
Here is an example of using GoAWS.jl’s SQS features from the package’s README:
using AWS, GoAWS
@service SQS use_response_type = true
with_go_aws() do aws_config
# Create the queue
result = parse(SQS.create_queue("my_queue"; aws_config))
queue_url = result["CreateQueueResult"]["QueueUrl"]
# Send a message
ret = parse(SQS.send_message("hello", queue_url; aws_config))
id = ret["SendMessageResult"]["MessageId"]
# Receive the message
messages = parse(SQS.receive_message(queue_url, Dict("WaitTimeSeconds" => 1); aws_config))
@test messages["ReceiveMessageResult"]["Message"]["Body"] == "hello"
receipt = messages["ReceiveMessageResult"]["Message"]["ReceiptHandle"]
@test startswith(receipt, id)
# Delete the message to mark is as done
SQS.delete_message(queue_url, receipt; aws_config)
# Here we clean up by deleting the queue
SQS.delete_queue(queue_url; aws_config)
end
This code spins up a GoAWS server on localhost and provides an aws_config
to interact with it using AWS.jl. However one can also construct an GoAWSConfig()
directly, e.g. to communicate with a server spun up elsewhere (perhaps in a kubernetes namespace or docker-compose environment), or a GoAWS.jl server on another process.
I have not used SNS (via AWS or GoAWS), so I can’t comment on that.
The API and package code is based on @ExpandingMan’s Minio.jl which similarly provides a clone of AWS s3.
I chose goaws
over other SQS clones because it clearly describes the APIs it supports (which includes the ones I need) and because go code is very simple to package into an JLL. So far it has been working well enough for my needs. I will call out two things I have noticed so far:
- the default
goaws
config connects to a live SNS server presumably for testing purposes. GoAWS.jl provides it’s own default config which does not create any queues or connect to any SNS servers by default. - Passing floating point values to
SQS.change_visibility_timeout
is not supported by AWS. If you do so with GoAWS, it does not provide a nice error, but rather obscurego
panics. I have added this to a troubleshooting section of the docs.
This code was developed at Beacon Biosignals and open-sourced today. It will be registered in General 3 days.