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 =
Jets.config.prewarm.enable
- CONCURRENCY =
Jets.config.prewarm.concurrency
- PREWARM_RATE =
Jets.config.prewarm.rate
Instance Attribute Summary
Attributes inherited from Lambda::Functions
Class Method Summary collapse
-
.prewarm! ⇒ Object
Can use this to prewarm post deploy.
Instance Method Summary collapse
Methods inherited from Job::Base
perform_later, perform_now, process
Methods included from Job::Helpers::SqsEventHelper
Methods included from Job::Helpers::SnsEventHelper
Methods included from Job::Helpers::S3EventHelper
Methods included from Job::Helpers::LogEventHelper
Methods included from Job::Helpers::KinesisEventHelper
Methods inherited from Lambda::Functions
inherited, #initialize, output_keys, subclasses
Methods included from Lambda::Dsl
Constructor Details
This class inherits a constructor from Jets::Lambda::Functions
Class Method Details
.prewarm! ⇒ Object
Can use this to prewarm post deploy
57 58 59 60 |
# File 'lib/jets/internal/app/jobs/jets/preheat_job.rb', line 57 def prewarm! meth = CONCURRENCY > 1 ? :torch : :warm perform_now(meth, quiet: true) end |
Instance Method Details
#torch ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jets/internal/app/jobs/jets/preheat_job.rb', line 30 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 Jets.env.test? end end threads.each { |t| t.join } "Finished prewarming your application with a concurrency of #{CONCURRENCY}." end |