Module: Aws::Rails::SqsActiveJob
- Defined in:
- lib/aws/rails/sqs_active_job/poller.rb,
lib/aws/rails/sqs_active_job/executor.rb,
lib/aws/rails/sqs_active_job/job_runner.rb,
lib/aws/rails/sqs_active_job/configuration.rb,
lib/aws/rails/sqs_active_job/lambda_handler.rb
Defined Under Namespace
Classes: Configuration, Executor, Interrupt, JobRunner, Poller
Class Method Summary collapse
-
.config ⇒ Configuration
The (singleton) Configuration.
- .configure { ... } ⇒ Object
- .fifo?(queue_url) ⇒ Boolean
-
.lambda_job_handler(event:, context:) ⇒ Object
A lambda event handler to run jobs from an SQS queue trigger Trigger the lambda from your SQS queue Configure the entrypoint to:
config/environment.Aws::Rails::SqsActiveJob.lambda_job_handler
This will load your Rails environment, and then use this method as the handler.
Class Method Details
.config ⇒ Configuration
Returns the (singleton) Configuration.
8 9 10 |
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 8 def self.config @config ||= Configuration.new end |
.configure { ... } ⇒ Object
13 14 15 |
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 13 def self.configure yield(config) end |
.fifo?(queue_url) ⇒ Boolean
17 18 19 |
# File 'lib/aws/rails/sqs_active_job/configuration.rb', line 17 def self.fifo?(queue_url) queue_url.ends_with? '.fifo' end |
.lambda_job_handler(event:, context:) ⇒ Object
A lambda event handler to run jobs from an SQS queue trigger Trigger the lambda from your SQS queue Configure the entrypoint to: config/environment.Aws::Rails::SqsActiveJob.lambda_job_handler
This will load your Rails environment, and then use this method as the handler.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aws/rails/sqs_active_job/lambda_handler.rb', line 13 def self.lambda_job_handler(event:, context:) return 'no records to process' unless event['Records'] event['Records'].each do |record| sqs_msg = to_sqs_msg(record) job = Aws::Rails::SqsActiveJob::JobRunner.new(sqs_msg) puts("Running job: #{job.id}[#{job.class_name}]") job.run sqs_msg.delete end "Processed #{event['Records'].length} jobs." end |