Class: Fixer::SqsClient
Constant Summary
Configuration::DEFAULT_ADAPTER, Configuration::DEFAULT_ENDPOINT, Configuration::DEFAULT_QUEUE, Configuration::DEFAULT_USER_AGENT, Configuration::VALID_OPTIONS_KEYS
Instance Method Summary
collapse
#configure, extended, keys, #options, #reset!
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ SqsClient
Returns a new instance of SqsClient.
31
32
33
34
|
# File 'lib/fixer/sqs_client.rb', line 31
def initialize(options = {})
apply_options(options)
yield(self) if block_given?
end
|
Instance Method Details
#apply_options(options = {}) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/fixer/sqs_client.rb', line 36
def apply_options(options = {})
current_options = Fixer.options.merge(options).with_indifferent_access
Fixer::Configuration.keys.each do |key|
send("#{key}=", current_options[key])
end
end
|
#create_job(job, opts = {}) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/fixer/sqs_client.rb', line 11
def create_job(job, opts = {})
job[:job][:id] ||= SecureRandom.uuid
job[:job][:client_id] ||= client_id
sqs_options = options.merge(opts)
sqs_queue = sqs_options[:queue]
conn = sqs(sqs_options[:aws])
queue_url = conn.get_queue_url(queue_name: sqs_queue).queue_url
conn.send_message(queue_url: queue_url, message_body: job.to_json)
job
end
|
#sqs(options = nil) ⇒ Object
23
24
25
|
# File 'lib/fixer/sqs_client.rb', line 23
def sqs(options = nil)
@sqs ||= Aws::SQS::Client.new(options)
end
|
#sqs=(sqs) ⇒ Object
27
28
29
|
# File 'lib/fixer/sqs_client.rb', line 27
def sqs=(sqs)
@sqs = sqs
end
|