jets 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/jets/core.rb +34 -0
- data/lib/jets/internal/app/jobs/jets/preheat_job.rb +2 -2
- data/lib/jets/processors/main_processor.rb +7 -1
- data/lib/jets/ruby_server.rb +2 -0
- data/lib/jets/version.rb +1 -1
- data/vendor/lambdagem/lib/lambdagem/extract/gem.rb +1 -1
- data/vendor/lambdagem/lib/lambdagem/extract/ruby.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b8471d0065ecdd475bc5aa957e80691f71a7754a5cbb7aad66f30b559ee4fc3
|
4
|
+
data.tar.gz: 196bcb78a37694d17849d9ee16153bb39f7ceb85a1e5d3e9eece9499125cbe13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
2
|
+
enabled = Jets.config.prewarm.enable
|
3
3
|
ENABLED = enabled.nil? ? true : enabled # defaults to enabled
|
4
|
-
CONCURRENCY = Jets.config.prewarm.concurrency ||
|
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.
|
data/lib/jets/ruby_server.rb
CHANGED
@@ -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
@@ -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
|
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}
|
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)
|