Class: Jets::PreheatJob
- Inherits:
-
ApplicationJob
- Object
- Lambda::Functions
- Job::Base
- ApplicationJob
- Jets::PreheatJob
- Defined in:
- lib/jets/internal/app/jobs/jets/preheat_job.rb
Constant Summary collapse
- ENABLED =
defaults to enabled
enabled.nil? ? true : enabled
- CONCURRENCY =
Jets.config.prewarm.concurrency || 2
- PREWARM_RATE =
Jets.config.prewarm.rate || '30 minutes'
Instance Attribute Summary
Attributes inherited from Lambda::Functions
Instance Method Summary collapse
Methods inherited from Job::Base
perform_later, perform_now, process
Methods inherited from Lambda::Functions
Methods included from Lambda::Dsl
Constructor Details
This class inherits a constructor from Jets::Lambda::Functions
Instance Method Details
#torch ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jets/internal/app/jobs/jets/preheat_job.rb', line 14 def torch threads = [] CONCURRENCY.times do threads << Thread.new do # intentionally calling remote lambda for concurrency # avoid passing the _prewarm=1 flag because we want the PreheatJob#warm # to run it's normal workload. # Do not use Jets::Preheat.warm(function_name) here as that passes the _prewarm=1. function_name = "jets-preheat_job-warm" event_json = JSON.dump(event) = (event[:quiet]) Jets::Commands::Call.new(function_name, event_json, ).run unless ENV['TEST'] end end threads.each { |t| t.join } "Finished prewarming your application with a concurrency of #{CONCURRENCY}." end |