Sha256: faf0b398782386e92d5aea9a25d26c85a0189777fcb2126b2dc5db3641d5cbac
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'socket' require 'fog' require 'eventmachine' module Udp2sqsServer class Server def initialize @host, @port, @threadpool_size = "0.0.0.0", 9732, 100 end def configure(host: "0.0.0.0", port: 9732, threadpool_size: 100) @host, @port, @threadpool_size = host, port, threadpool_size end def run EM.threadpool_size = @threadpool_size EM.run do warmup_threads = proc do i = 0 i += 1 end EM.defer(warmup_threads) config = YAML.load_file("queue.yaml") s = UDPSocket.new s.bind(@host, @port) loop do text, sender = s.recvfrom(1024) operation = proc do sqs = Fog::AWS::SQS.new( :aws_access_key_id => config['access_key'], :aws_secret_access_key => config['secret_key'], :region => config['queue_region'] ) sqs.send_message(config['queue_url'], text) end EM.defer(operation) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
udp2sqs_server-0.1.0 | lib/udp2sqs_server/server.rb |