Class: Jets::Shim::Adapter::Prewarm

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/shim/adapter/prewarm.rb

Constant Summary collapse

@@prewarm_count =
0
@@prewarm_at =
nil

Instance Attribute Summary

Attributes inherited from Base

#context, #event, #target

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Util::Logging

#log

Constructor Details

This class inherits a constructor from Jets::Shim::Adapter::Base

Class Method Details

.statsObject



18
19
20
21
22
23
24
25
# File 'lib/jets/shim/adapter/prewarm.rb', line 18

def self.stats
  {
    boot_at: Jets::Core::Booter.boot_at,
    gid: Jets::Core::Booter.gid,
    prewarm_at: @@prewarm_at,
    prewarm_count: @@prewarm_count
  }
end

Instance Method Details

#handleObject



6
7
8
9
10
11
12
# File 'lib/jets/shim/adapter/prewarm.rb', line 6

def handle
  @@prewarm_count += 1
  @@prewarm_at = Time.now.utc
  result = self.class.stats
  log.info "Prewarm request: #{JSON.dump(result)}" if ENV["JETS_PREWARM_LOG"]
  result
end

#handle?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/jets/shim/adapter/prewarm.rb', line 14

def handle?
  event["_prewarm"]
end