jets 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 921ded61512a3d89dd910a7af606e589b2c64b3fb6269cc0804cc39aee2da037
4
- data.tar.gz: faf32f17f5b2fab7a1067c7dd656d26d6ccdace59fcd2c2e6898f24420e088b5
3
+ metadata.gz: 2b8471d0065ecdd475bc5aa957e80691f71a7754a5cbb7aad66f30b559ee4fc3
4
+ data.tar.gz: 196bcb78a37694d17849d9ee16153bb39f7ceb85a1e5d3e9eece9499125cbe13
5
5
  SHA512:
6
- metadata.gz: 7963cd9338daca100b5e0b4c60e24c9f4d0d92153b21e3f10f1a060ff9b4d015a499ab4ae54c6d3ee804e32ecd7c1c64cdaa9d2bb2155308f85ae1c6316af7d7
7
- data.tar.gz: 3e19e2c9d11d048712aee34bba5036c6995fc35d429a058e7015d025c419f86713b02c7886eaf9cb9677dc9a8df78ca55c7e6af65b79d77002b2488abd81bb4c
6
+ metadata.gz: c922aa0f644d331e387f448673da9bc674fa9b78095646a686a815f557ee34d6525f3ea186a35b3f04ca51caab699352a86aac7fa7a15e7a7124676c1b2105a3
7
+ data.tar.gz: 3973fc0339e6f8a7d2a1d720df63024e9ad7be143ae82e5c78ebd0970a3e50d0e23cababcae79795eed6c449683e30704d26bbc44349c216ee21e276f1ea0364
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.5.3]
7
+ - add x-jets-prewarm-count and x-jets-call-count headers: pull request #10 from tongueroo/call-count
8
+ - adjust default prewarming concurrency to 2
9
+ - Jets.eager_load as part of warmup
10
+ - rename config.prewarm.enable
11
+ - update docs
12
+
6
13
  ## [0.5.2]
7
14
  - format the js error in the node shim properly
8
15
 
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (0.5.2)
14
+ jets (0.5.3)
15
15
  actionpack
16
16
  actionview
17
17
  activerecord
data/lib/jets/core.rb CHANGED
@@ -77,5 +77,39 @@ module Jets::Core
77
77
  def version
78
78
  Jets::VERSION
79
79
  end
80
+
81
+ def eager_load!
82
+ Dir.glob("#{Jets.root}app/**/*.rb").select do |path|
83
+ next if !File.file?(path) or path =~ %r{/javascript/} or path =~ %r{/views/}
84
+
85
+ class_name = path
86
+ .sub(/\.rb$/,'') # remove .rb
87
+ .sub(/^\.\//,'') # remove ./
88
+ .sub(/app\/\w+\//,'') # remove app/controllers or app/jobs etc
89
+ .classify
90
+ puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['DEBUG']
91
+ class_name.constantize # dont have to worry about order.
92
+ end
93
+ end
94
+
95
+ # NOTE: In development this will always be 1 because the app gets reloaded.
96
+ # On AWS Lambda, this will be ever increasing until the container gets replaced.
97
+ @@call_count = 0
98
+ def increase_call_count
99
+ @@call_count += 1
100
+ end
101
+
102
+ def call_count
103
+ @@call_count
104
+ end
105
+
106
+ @@prewarm_count = 0
107
+ def increase_prewarm_count
108
+ @@prewarm_count += 1
109
+ end
110
+
111
+ def prewarm_count
112
+ @@prewarm_count
113
+ end
80
114
 
81
115
  end
@@ -1,7 +1,7 @@
1
1
  class Jets::PreheatJob < ApplicationJob
2
- enabled = Jets.config.prewarm.enabled
2
+ enabled = Jets.config.prewarm.enable
3
3
  ENABLED = enabled.nil? ? true : enabled # defaults to enabled
4
- CONCURRENCY = Jets.config.prewarm.concurrency || 1
4
+ CONCURRENCY = Jets.config.prewarm.concurrency || 2
5
5
  PREWARM_RATE = Jets.config.prewarm.rate || '30 minutes'
6
6
  torching = ENABLED && CONCURRENCY > 1
7
7
  warming = ENABLED && CONCURRENCY == 1
@@ -31,13 +31,19 @@ class Jets::Processors::MainProcessor
31
31
  result = instance_eval(deducer.code, deducer.path)
32
32
  # result = PostsController.process(event, context, "create")
33
33
 
34
+ Jets.increase_call_count
35
+ if result.is_a?(Hash) && result["headers"]
36
+ result["headers"]["x-jets-call-count"] = Jets.call_count
37
+ result["headers"]["x-jets-prewarm-count"] = Jets.prewarm_count
38
+ end
39
+
34
40
  # Puts the return value of project code to stdout because this is
35
41
  # what eventually gets used by API Gateway.
36
42
  # Explicitly using $stdout since puts has been redirected to $stderr.
37
43
  #
38
44
  # JSON.dump is pretty robust. If it cannot dump the structure into a
39
45
  # json string, it just dumps it to a plain text string.
40
- Jets::Util.normalize_result(result) # String
46
+ resp = Jets::Util.normalize_result(result) # String
41
47
  rescue Exception => e
42
48
  # Customize error message slightly so nodejs shim can process the
43
49
  # returned error message.
@@ -17,6 +17,7 @@ module Jets
17
17
  def run
18
18
  $stdout.sync = true
19
19
  Jets.boot # outside of child process for COW
20
+ Jets.eager_load!
20
21
 
21
22
  # INT - ^C
22
23
  trap('INT') do
@@ -67,6 +68,7 @@ module Jets
67
68
 
68
69
  def prewarm_request(event)
69
70
  # JSON.dump("prewarmed_at" => Time.now.to_s)
71
+ Jets.increase_prewarm_count
70
72
  %Q|{"prewarmed_at":"#{Time.now.to_s}"}| # raw json for speed
71
73
  end
72
74
 
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -13,7 +13,7 @@ module Lambdagem::Extract
13
13
  VERSION_PATTERN = /-(\d+\.\d+\.\d+.*)/
14
14
 
15
15
  def run
16
- puts "Looking for #{full_gem_name} gem in s3 bucket: #{@options[:s3]}"
16
+ puts "Looking for #{full_gem_name} gem in: #{@options[:lambdagems_url]}"
17
17
  clean_downloads(:gems) if @options[:clean]
18
18
  tarball_path = download_gem
19
19
  remove_current_gem
@@ -11,7 +11,7 @@ module Lambdagem::Extract
11
11
  class NotFound < RuntimeError; end
12
12
 
13
13
  def run
14
- puts "Looking for #{full_ruby_name} in S3 bucket: #{@options[:s3]}"
14
+ puts "Looking for #{full_ruby_name}"
15
15
  clean_downloads(:rubies) if @options[:clean]
16
16
  tarball_path = download_ruby
17
17
  unpack_tarball(tarball_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen