aws-sqs

aws-sqs is the unofficial AWS SQS library for the Crystal.

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  aws-sqs:
    github: maiha/aws-sqs.cr
  1. Run shards install

Usage

require "aws-sqs"

client = Aws::SQS::Client.new("us-east-2", "key", "secret")

client.list_queues
client.get_queue_attributes(queue_url: queue_url, attribute_names: ["QueueArn", "ApproximateNumberOfMessages"])
client.send_message(queue_url: queue_url, message_body: "message")
client.send_message(queue_url: queue_url, message_body: "message", message_group_id: "g1", message_deduplication_id: "d1")
client.receive_message(queue_url: queue_url)
client.delete_message(queue_url: queue_url, receipt_handle: "MbZj6wDWli...")
client.change_message_visibility(queue_url: queue_url, receipt_handle: "MbZj6wDWli...", visibility_timeout: 60)

Samples

$ export AWS_DEFAULT_REGION=us-east-2
$ export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
$ export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

$ crystal samples/list_queues.cr
$ crystal samples/get_queue_attributes.cr      "https://.../MyQueue"
$ crystal samples/send_message.cr              "https://.../MyQueue" "hello"
$ crystal samples/receive_message.cr           "https://.../MyQueue"
$ crystal samples/delete_message.cr            "https://.../MyQueue" "MbZj6wDWli..."
$ crystal samples/change_message_visibility.cr "https://.../MyQueue" "MbZj6wDWli..." 60

API

Development

$ crystal spec

Contributing

  1. Fork it (https://github.com/maiha/aws-sqs.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Thanks