Skip to content

Instantly share code, notes, and snippets.

@allcentury
Created October 14, 2015 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allcentury/302b6650ded5748dcc47 to your computer and use it in GitHub Desktop.
Save allcentury/302b6650ded5748dcc47 to your computer and use it in GitHub Desktop.
class SQS
attr_reader :aws, :queue_url
def initialize(aws)
@aws = aws
@queue_url = "https://sqs.us-east-1.amazonaws.com/my-topic-for-sqs"
end
def publish_msg(msg)
aws.send_message(queue_url: queue_url, message_body: JSON.generate(msg))
end
end
sqs = SQS.new(Aws::SQS::Client.new)
# users is just an array of hashes
users.each do |user|
# i'd like this to be async
sqs.publish_msg(user)
end
# I don't want the program to end until all threads have finished
@jdantonio
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment