jets 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 705c645de879c7e521d0dcb66b90b37e4360c67510ab8ffb8ad16e8755093704
4
- data.tar.gz: 3a50bef872e5c8851d95fc4ece586ab3b3b006bfaafc752e959d01a58d32674f
3
+ metadata.gz: c23297d5a96505bc116becff6a604539afd6254dc1d82d2183690db0ad844ada
4
+ data.tar.gz: e5f71634747079332df18153423ff478b824eda518771142a648fd050183da8c
5
5
  SHA512:
6
- metadata.gz: 34a5e03a72d87f5cab1a02a555e5c9c30c026cc535c1bb4a1c609171201e1c9c9ff8f07f460ef90431a47fd2ed6afac4de9f663fb06ee16747ad1b10f0722b91
7
- data.tar.gz: 412567cb2846d8d9e0c00c4e9ea8a7e87c775b6ad2220f3e0d0c7d0723a4203bc7730afef6a67a1474caaa0d66a4d7d47af15f7caad2fd1aecac0adf48a36f5a
6
+ metadata.gz: 98d0b905f7616e1a295da9e4e79577a242985f48d9f8f4488bb7e419776d162a52f045a314ea0988450394b61d8c8759d588b5fe51acf07704bdd3a6c93b5249
7
+ data.tar.gz: f5d340c2bcdd5063fa474c8222f32e026099ec9eb371e1b30f67e5bbd84de260c4c5ccf70f480440b7194d5dbab415e8b64a9f02537372f266856be49e326778
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [1.0.17]
7
+ - Initial Jets Turbine support. http://rubyonjets.com/docs/jets-turbines/
8
+ - pull request #71 from tongueroo/turbine
9
+ - Addresses #70 Exception reporting
10
+
6
11
  ## [1.0.16]
7
12
  - fix application iam policy when Jets::Application.default_iam_policy is used in config/application.rb
8
13
  - #69 from tongueroo/fix-app-iam-policy
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (1.0.16)
14
+ jets (1.0.17)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -65,14 +65,14 @@ GEM
65
65
  tzinfo (~> 1.1)
66
66
  arel (9.0.0)
67
67
  aws-eventstream (1.0.1)
68
- aws-partitions (1.111.0)
69
- aws-sdk-cloudformation (1.10.0)
68
+ aws-partitions (1.113.0)
69
+ aws-sdk-cloudformation (1.11.0)
70
70
  aws-sdk-core (~> 3, >= 3.26.0)
71
71
  aws-sigv4 (~> 1.0)
72
72
  aws-sdk-cloudwatchlogs (1.10.0)
73
73
  aws-sdk-core (~> 3, >= 3.26.0)
74
74
  aws-sigv4 (~> 1.0)
75
- aws-sdk-core (3.37.0)
75
+ aws-sdk-core (3.38.0)
76
76
  aws-eventstream (~> 1.0)
77
77
  aws-partitions (~> 1.0)
78
78
  aws-sigv4 (~> 1.0)
@@ -90,7 +90,7 @@ GEM
90
90
  aws-sdk-core (~> 3, >= 3.26.0)
91
91
  aws-sdk-kms (~> 1)
92
92
  aws-sigv4 (~> 1.0)
93
- aws-sdk-sns (1.7.0)
93
+ aws-sdk-sns (1.8.0)
94
94
  aws-sdk-core (~> 3, >= 3.26.0)
95
95
  aws-sigv4 (~> 1.0)
96
96
  aws-sigv4 (1.0.3)
@@ -114,7 +114,7 @@ GEM
114
114
  crass (~> 1.0.2)
115
115
  nokogiri (>= 1.5.9)
116
116
  memoist (0.16.0)
117
- method_source (0.9.1)
117
+ method_source (0.9.2)
118
118
  mimemagic (0.3.2)
119
119
  mini_portile2 (2.3.0)
120
120
  minitest (5.11.3)
data/lib/jets.rb CHANGED
@@ -46,6 +46,7 @@ module Jets
46
46
  autoload :Server, "jets/server"
47
47
  autoload :Stack, "jets/stack"
48
48
  autoload :Timing, "jets/timing"
49
+ autoload :Turbine, 'jets/turbine'
49
50
  autoload :Util, "jets/util"
50
51
 
51
52
  extend Core # root, logger, etc
data/lib/jets/booter.rb CHANGED
@@ -10,10 +10,26 @@ class Jets::Booter
10
10
  Jets::Dotenv.load!
11
11
  Jets.application # triggers application.setup! # autoload_paths, routes, etc
12
12
  setup_db
13
+ app_initializers
14
+ turbine_initializers
13
15
 
14
16
  @booted = true
15
17
  end
16
18
 
19
+ def turbine_initializers
20
+ Jets::Turbine.subclasses.each do |subclass|
21
+ subclass.initializers.each do |label, block|
22
+ block.call(Jets.application)
23
+ end
24
+ end
25
+ end
26
+
27
+ def app_initializers
28
+ Dir.glob("#{Jets.root}config/initializers/**/*").each do |path|
29
+ load path
30
+ end
31
+ end
32
+
17
33
  # AWS Lambda for natively supported languages prints to CloudWatch instead of
18
34
  # mungling up the response. We'll redirect stdout to stderr to mimic AWS Lambda
19
35
  # behavior.
data/lib/jets/core.rb CHANGED
@@ -174,4 +174,12 @@ module Jets::Core
174
174
  return true if ENV['JETS_POLY_ONLY'] # bypass to allow rapid development of handlers
175
175
  Jets::Commands::Build.poly_only?
176
176
  end
177
+
178
+ def report_exception(exception)
179
+ Jets::Turbine.subclasses.each do |subclass|
180
+ subclass.exception_reporters.each do |label, block|
181
+ block.call(exception)
182
+ end
183
+ end
184
+ end
177
185
  end
data/lib/jets/poly_fun.rb CHANGED
@@ -22,7 +22,7 @@ module Jets
22
22
  if task.lang == :ruby
23
23
  # controller = PostsController.new(event, content)
24
24
  # resp = controller.edit
25
- @app_class.process(event, context, @app_meth)
25
+ run_ruby_code(event, context)
26
26
  else
27
27
  executor = LambdaExecutor.new(task)
28
28
  resp = executor.run(event, context)
@@ -33,6 +33,12 @@ module Jets
33
33
  end
34
34
  end
35
35
 
36
+ def run_ruby_code(event, context)
37
+ @app_class.process(event, context, @app_meth)
38
+ rescue Exception => e
39
+ Jets.report_exception(e)
40
+ end
41
+
36
42
  def raise_error(resp)
37
43
  backtrace = resp["stackTrace"] + caller
38
44
  backtrace = backtrace.map { |l| l.sub(/^\s+/,'') }
@@ -46,18 +46,19 @@ class Jets::Processors::MainProcessor
46
46
  # json string, it just dumps it to a plain text string.
47
47
  Jets::Util.normalize_result(result) # resp is a String
48
48
  rescue Exception => e
49
- # Customize error message slightly so nodejs shim can process the
50
- # returned error message.
51
- # The "RubyError: " is a marker that the javascript shim scans for.
52
- $stderr.puts("RubyError: #{e.class}: #{e.message}") # js needs this as the first line
53
- backtrace = e.backtrace.map {|l| " #{l}" }
54
- $stderr.puts(backtrace)
55
- # No need to having error in stderr above anymore because errors are handled in memory
56
- # at ruby_server.rb but keeping around for posterity.
49
+ unless ENV['TEST']
50
+ # Customize error message slightly so nodejs shim can process the
51
+ # returned error message.
52
+ # The "RubyError: " is a marker that the javascript shim scans for.
53
+ $stderr.puts("RubyError: #{e.class}: #{e.message}") # js needs this as the first line
54
+ backtrace = e.backtrace.map {|l| " #{l}" }
55
+ $stderr.puts(backtrace)
56
+ # No need to having error in stderr above anymore because errors are handled in memory
57
+ # at ruby_server.rb but keeping around for posterity.
58
+ end
57
59
 
60
+ Jets.report_exception(e)
58
61
  raise # raise error to ruby_server.rb to rescue and handle
59
-
60
- # $stderr.puts("END OF RUBY OUTPUT") # uncomment for debugging
61
62
  end
62
63
  end
63
64
  end
@@ -0,0 +1,26 @@
1
+ module Jets
2
+ class Turbine
3
+ class_attribute :initializers
4
+ class_attribute :exception_reporters
5
+
6
+ class << self
7
+ def subclasses
8
+ @subclasses ||= []
9
+ end
10
+
11
+ def inherited(base)
12
+ subclasses << base
13
+ end
14
+
15
+ def initializer(label, &block)
16
+ self.initializers ||= {}
17
+ self.initializers[label] = block
18
+ end
19
+
20
+ def exception_reporter(label, &block)
21
+ self.exception_reporters ||= {}
22
+ self.exception_reporters[label] = block
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "1.0.16"
2
+ VERSION = "1.0.17"
3
3
  end
@@ -3,6 +3,9 @@
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
+ ## [1.0.8]
7
+ - scope endpoint option to dynamodb client only vs the entire Aws.config
8
+
6
9
  ## [1.0.7]
7
10
  - update DYNOMITE_ENV var
8
11
 
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dynomite (1.0.8)
5
+ activesupport
6
+ aws-sdk-dynamodb
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.2.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ aws-eventstream (1.0.1)
17
+ aws-partitions (1.111.0)
18
+ aws-sdk-core (3.38.0)
19
+ aws-eventstream (~> 1.0)
20
+ aws-partitions (~> 1.0)
21
+ aws-sigv4 (~> 1.0)
22
+ jmespath (~> 1.0)
23
+ aws-sdk-dynamodb (1.16.0)
24
+ aws-sdk-core (~> 3, >= 3.26.0)
25
+ aws-sigv4 (~> 1.0)
26
+ aws-sigv4 (1.0.3)
27
+ concurrent-ruby (1.1.3)
28
+ diff-lcs (1.3)
29
+ i18n (1.1.1)
30
+ concurrent-ruby (~> 1.0)
31
+ jmespath (1.4.0)
32
+ minitest (5.11.3)
33
+ rake (12.3.1)
34
+ rspec (3.8.0)
35
+ rspec-core (~> 3.8.0)
36
+ rspec-expectations (~> 3.8.0)
37
+ rspec-mocks (~> 3.8.0)
38
+ rspec-core (3.8.0)
39
+ rspec-support (~> 3.8.0)
40
+ rspec-expectations (3.8.2)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.8.0)
43
+ rspec-mocks (3.8.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.8.0)
46
+ rspec-support (3.8.0)
47
+ thread_safe (0.3.6)
48
+ tzinfo (1.2.5)
49
+ thread_safe (~> 0.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ bundler
56
+ dynomite!
57
+ rake
58
+ rspec
59
+
60
+ BUNDLED WITH
61
+ 1.16.3
@@ -50,7 +50,7 @@ post.attrs # {"id" => "myid", title" => "my title", desc: "my desc 2"}
50
50
 
51
51
  Note, a race condition edge case can exist when several concurrent replace
52
52
  calls are happening. This is why the interface is called replace to
53
- emphasis that possibility.
53
+ emphasize that possibility.
54
54
 
55
55
  ### Delete
56
56
 
@@ -26,8 +26,14 @@ module Dynomite::DbConfig
26
26
  endpoint = ENV['DYNAMODB_ENDPOINT'] || config['endpoint']
27
27
  check_dynamodb_local!(endpoint)
28
28
 
29
- Aws.config.update(endpoint: endpoint) if endpoint
30
- @@db ||= Aws::DynamoDB::Client.new
29
+ # Normally, do not set the endpoint to use the current configured region.
30
+ # Probably want to stay in the same region anyway for db connections.
31
+ #
32
+ # List of regional endpoints: https://docs.aws.amazon.com/general/latest/gr/rande.html#ddb_region
33
+ # Example:
34
+ # endpoint: https://dynamodb.us-east-1.amazonaws.com
35
+ options = endpoint ? { endpoint: endpoint } : {}
36
+ @@db ||= Aws::DynamoDB::Client.new(options)
31
37
  end
32
38
 
33
39
  # When endoint has been configured to point at dynamodb local: localhost:8000
@@ -1,3 +1,3 @@
1
1
  module Dynomite
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -0,0 +1,30 @@
1
+ class CommentsMigration < Dynomite::Migration
2
+ def up
3
+ create_table :comments do |t|
4
+ t.partition_key "post_id:string" # required
5
+ t.sort_key "created_at:string" # optional
6
+ t.provisioned_throughput(5) # sets both read and write, defaults to 5 when not set
7
+
8
+ # Instead of using partition_key and sort_key you can set the
9
+ # key schema directly also
10
+ # t.key_schema([
11
+ # {attribute_name: "id", :key_type=>"HASH"},
12
+ # {attribute_name: "created_at", :key_type=>"RANGE"}
13
+ # ])
14
+ # t.attribute_definitions([
15
+ # {attribute_name: "id", attribute_type: "N"},
16
+ # {attribute_name: "created_at", attribute_type: "S"}
17
+ # ])
18
+
19
+ # other ways to set provisioned_throughput
20
+ # t.provisioned_throughput(:read, 10)
21
+ # t.provisioned_throughput(:write, 10)
22
+ # t.provisioned_throughput(
23
+ # read_capacity_units: 5,
24
+ # write_capacity_units: 5
25
+ # )
26
+ end
27
+ end
28
+ end
29
+
30
+ # More examples: https://github.com/tongueroo/dynomite/tree/master/docs
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-11 00:00:00.000000000 Z
11
+ date: 2018-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -717,10 +717,12 @@ files:
717
717
  - lib/jets/stack/resource/dsl.rb
718
718
  - lib/jets/timing.rb
719
719
  - lib/jets/timing/report.rb
720
+ - lib/jets/turbine.rb
720
721
  - lib/jets/util.rb
721
722
  - lib/jets/version.rb
722
723
  - vendor/dynomite/CHANGELOG.md
723
724
  - vendor/dynomite/Gemfile
725
+ - vendor/dynomite/Gemfile.lock
724
726
  - vendor/dynomite/README.md
725
727
  - vendor/dynomite/Rakefile
726
728
  - vendor/dynomite/bin/console
@@ -745,7 +747,9 @@ files:
745
747
  - vendor/dynomite/lib/dynomite/migration/templates/create_table.rb
746
748
  - vendor/dynomite/lib/dynomite/migration/templates/update_table.rb
747
749
  - vendor/dynomite/lib/dynomite/version.rb
750
+ - vendor/dynomite/pkg/dynomite-1.0.8.gem
748
751
  - vendor/dynomite/spec/fixtures/app_root/config/dynamodb.yml
752
+ - vendor/dynomite/spec/fixtures/dynamodb/migrate/20181113165001-comments_migration.rb
749
753
  - vendor/dynomite/spec/lib/dynomite/item_spec.rb
750
754
  - vendor/dynomite/spec/lib/dynomite/migration/dsl/global_secondary_index_spec.rb
751
755
  - vendor/dynomite/spec/lib/dynomite/migration/dsl/local_secondary_index_spec.rb