funktor 0.2.16 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/funktor.rb +39 -2
  4. data/lib/funktor/active_job_handler.rb +2 -2
  5. data/lib/funktor/cli/bootstrap.rb +9 -1
  6. data/lib/funktor/cli/init.rb +14 -14
  7. data/lib/funktor/cli/templates/{config → funktor_config}/boot.rb +0 -0
  8. data/lib/funktor/cli/templates/{config → funktor_config}/environment.yml +0 -0
  9. data/lib/funktor/cli/templates/{config → funktor_config}/function_definitions/incoming_job_handler.yml +0 -0
  10. data/lib/funktor/cli/templates/{config → funktor_config}/function_definitions/work_queue_handler.yml +0 -0
  11. data/lib/funktor/cli/templates/{config → funktor_config}/funktor.yml +0 -0
  12. data/lib/funktor/cli/templates/{config → funktor_config}/iam_permissions/incoming_job_queue.yml +0 -0
  13. data/lib/funktor/cli/templates/{config → funktor_config}/iam_permissions/ssm.yml +0 -0
  14. data/lib/funktor/cli/templates/{config → funktor_config}/iam_permissions/work_queue.yml +0 -0
  15. data/lib/funktor/cli/templates/{config → funktor_config}/package.yml +1 -1
  16. data/lib/funktor/cli/templates/{config → funktor_config}/resources/cloudwatch_dashboard.yml +127 -53
  17. data/lib/funktor/cli/templates/{config → funktor_config}/resources/incoming_job_queue.yml +0 -0
  18. data/lib/funktor/cli/templates/{config → funktor_config}/resources/incoming_job_queue_user.yml +0 -0
  19. data/lib/funktor/cli/templates/{config → funktor_config}/resources/work_queue.yml +0 -0
  20. data/lib/funktor/cli/templates/{config → funktor_config}/ruby_layer.yml +0 -0
  21. data/lib/funktor/cli/templates/funktor_init.yml.tt +1 -1
  22. data/lib/funktor/cli/templates/lambda_event_handlers/incoming_job_handler.rb +1 -4
  23. data/lib/funktor/cli/templates/lambda_event_handlers/work_queue_handler.rb +1 -1
  24. data/lib/funktor/cli/templates/serverless.yml +4 -4
  25. data/lib/funktor/error_handler.rb +25 -0
  26. data/lib/funktor/logger.rb +5 -0
  27. data/lib/funktor/version.rb +1 -1
  28. metadata +20 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa01638d668cf37cb97173784714a5339a13d37b4dbbc1c55edf5d4633f034de
4
- data.tar.gz: a245b13673f1eabd8721468638205e9da36f75a6892389cc8156ecee4d6d1bf3
3
+ metadata.gz: 5dad52e1f8c07a2cf42ec9029920e80cc4152870a0fc863c35ad8015dfe5eac1
4
+ data.tar.gz: a22bbf4322188071bb1290f4d189f2fb3c6f80fe2ec6a8fe8c8e150887808007
5
5
  SHA512:
6
- metadata.gz: 5f4ea8b57070bb603e33edb9dbad4a088b1c7deb3b8e5e34c1c2667a063c421a4cf843eae7a495a9762a00fd2bbce8316c7c38f287ad0e7c7e02003941fd5885
7
- data.tar.gz: f550064ade4cb5dabf889f4cccdff22b065806e79043086aa86b95592dd7f665da7de2afe63402a15470f491002f90153cb70d8bacd17fe9f7b260cced77170f
6
+ metadata.gz: 669ee84b2d8e0261886484e365631eaea64ea7a8bb3c3528fce1edebdfa2bb4da61be55e64346a3a4f3b4f7eb5c4dbaebc0ce622a81ae887dc056effa983caa4
7
+ data.tar.gz: d5ef08ff4ca811a24131fc16fb38dffb8f0ddb9ff777d96408bd0ab9c4c6d498a9d430cee8af2feba6cad38090a26f952480ead4e16a7336095fe21e28fedc31
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- funktor (0.2.16)
4
+ funktor (0.2.19)
5
5
  activesupport
6
6
  aws-sdk-sqs (~> 1.37)
7
7
  thor
data/lib/funktor.rb CHANGED
@@ -3,16 +3,21 @@ require 'funktor/aws/sqs/event'
3
3
  require 'funktor/aws/sqs/record'
4
4
  require 'funktor/counter'
5
5
  require 'funktor/job'
6
+ require 'funktor/logger'
6
7
  require 'funktor/worker'
7
8
  require 'funktor/middleware_chain'
8
9
  require 'funktor/incoming_job_handler'
9
- require 'funktor/active_job_handler'
10
10
 
11
11
  require 'json'
12
12
 
13
13
  module Funktor
14
14
  class Error < StandardError; end
15
15
 
16
+ DEFAULT_OPTIONS = {
17
+ error_handlers: [],
18
+ log_level: Logger::DEBUG # Set a high log level during early, active development
19
+ }
20
+
16
21
  def self.configure_job_pusher
17
22
  yield self
18
23
  end
@@ -55,9 +60,41 @@ module Funktor
55
60
  def self.dump_json(object)
56
61
  JSON.generate(object)
57
62
  end
63
+
64
+ def self.options
65
+ @options ||= DEFAULT_OPTIONS.dup
66
+ end
67
+
68
+ def self.options=(opts)
69
+ @options = opts
70
+ end
71
+
72
+ # Register a proc to handle any error which occurs within the Funktor active job handler.
73
+ #
74
+ # Funktor.error_handlers << proc {|error, context| ErrorsAsAService.notify(error, context) }
75
+ #
76
+ # The default error handler logs errors to STDOUT
77
+ def self.error_handlers
78
+ options[:error_handlers]
79
+ end
80
+
81
+ def self.logger
82
+ @logger ||= Funktor::Logger.new($stdout, level: options[:log_level])
83
+ end
84
+
85
+ def self.logger=(logger)
86
+ if logger.nil?
87
+ self.logger.level = Logger::FATAL
88
+ return self.logger
89
+ end
90
+
91
+ @logger = logger
92
+ end
58
93
  end
59
94
 
60
95
  # TODO - Should we require this by default or let people opt in?
61
- # Is it a code smell that we need to include it at the bottom, after
96
+ # TODO - Is it a code smell that we need to include these at the bottom, after
62
97
  # the main Funktor module is defined?
63
98
  require 'funktor/middleware/metrics'
99
+ require 'funktor/error_handler'
100
+ require 'funktor/active_job_handler'
@@ -2,6 +2,7 @@ require 'aws-sdk-sqs'
2
2
 
3
3
  module Funktor
4
4
  class ActiveJobHandler
5
+ include Funktor::ErrorHandler
5
6
 
6
7
  def initialize
7
8
  @failed_counter = Funktor::Counter.new('failed')
@@ -28,8 +29,7 @@ module Funktor
28
29
  @processed_counter.incr(job)
29
30
  # rescue Funktor::Job::InvalidJsonError # TODO Make this work
30
31
  rescue Exception => e
31
- puts "Error during processing: #{$!}"
32
- puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
32
+ handle_error(e, job)
33
33
  @failed_counter.incr(job)
34
34
  attempt_retry_or_bail(job)
35
35
  end
@@ -9,6 +9,10 @@ module Funktor
9
9
  :type => :string, :desc => "The bootstrap file to generate.",
10
10
  :default => "funktor_init.yml"
11
11
 
12
+ class_option :directory, :aliases => "-d",
13
+ :type => :string, :desc => "The directory in which to place the bootstrap file.",
14
+ :default => nil
15
+
12
16
  desc <<~DESC
13
17
  Description:
14
18
  Bootstrap a new funktor application by generating a funktor_init.yml file."
@@ -26,7 +30,11 @@ module Funktor
26
30
 
27
31
  private
28
32
  def funktor_file_target
29
- File.join name, options[:file]
33
+ File.join funktor_directory_target, options[:file]
34
+ end
35
+
36
+ def funktor_directory_target
37
+ options[:directory] || name
30
38
  end
31
39
 
32
40
  end
@@ -32,11 +32,11 @@ module Funktor
32
32
 
33
33
  def funktor_config_yml
34
34
  #template "funktor_config.yml", File.join("funktor_config.yml")
35
- template File.join("config", "funktor.yml"), File.join("config", "funktor.yml")
36
- template File.join("config", "ruby_layer.yml"), File.join("config", "ruby_layer.yml")
37
- template File.join("config", "package.yml"), File.join("config", "package.yml")
38
- template File.join("config", "environment.yml"), File.join("config", "environment.yml")
39
- template File.join("config", "boot.rb"), File.join("config", "boot.rb")
35
+ template File.join("funktor_config", "funktor.yml"), File.join("funktor_config", "funktor.yml")
36
+ template File.join("funktor_config", "ruby_layer.yml"), File.join("funktor_config", "ruby_layer.yml")
37
+ template File.join("funktor_config", "package.yml"), File.join("funktor_config", "package.yml")
38
+ template File.join("funktor_config", "environment.yml"), File.join("funktor_config", "environment.yml")
39
+ template File.join("funktor_config", "boot.rb"), File.join("funktor_config", "boot.rb")
40
40
  end
41
41
 
42
42
  def package_json
@@ -56,33 +56,33 @@ module Funktor
56
56
  end
57
57
 
58
58
  def resources
59
- template File.join("config", "resources", "incoming_job_queue.yml"), File.join("config", "resources", "incoming_job_queue.yml")
60
- template File.join("config", "resources", "incoming_job_queue_user.yml"), File.join("config", "resources", "incoming_job_queue_user.yml")
59
+ template File.join("funktor_config", "resources", "incoming_job_queue.yml"), File.join("funktor_config", "resources", "incoming_job_queue.yml")
60
+ template File.join("funktor_config", "resources", "incoming_job_queue_user.yml"), File.join("funktor_config", "resources", "incoming_job_queue_user.yml")
61
61
  # TODO - Figure out how to make the dashboard aware of various queues...
62
- template File.join("config", "resources", "cloudwatch_dashboard.yml"), File.join("config", "resources", "cloudwatch_dashboard.yml")
62
+ template File.join("funktor_config", "resources", "cloudwatch_dashboard.yml"), File.join("funktor_config", "resources", "cloudwatch_dashboard.yml")
63
63
  queues.each do |queue_details|
64
64
  @work_queue_name = queue_details.keys.first
65
65
  @work_queue_config = queue_details.values.first
66
- template File.join("config", "resources", "work_queue.yml"), File.join("config", "resources", "#{work_queue_name.underscore}_queue.yml")
66
+ template File.join("funktor_config", "resources", "work_queue.yml"), File.join("funktor_config", "resources", "#{work_queue_name.underscore}_queue.yml")
67
67
  end
68
68
  end
69
69
 
70
70
  def iam_permissions
71
- template File.join("config", "iam_permissions", "ssm.yml"), File.join("config", "iam_permissions", "ssm.yml")
72
- template File.join("config", "iam_permissions", "incoming_job_queue.yml"), File.join("config", "iam_permissions", "incoming_job_queue.yml")
71
+ template File.join("funktor_config", "iam_permissions", "ssm.yml"), File.join("funktor_config", "iam_permissions", "ssm.yml")
72
+ template File.join("funktor_config", "iam_permissions", "incoming_job_queue.yml"), File.join("funktor_config", "iam_permissions", "incoming_job_queue.yml")
73
73
  queues.each do |queue_details|
74
74
  @work_queue_name = queue_details.keys.first
75
75
  @work_queue_config = queue_details.values.first
76
- template File.join("config", "iam_permissions", "work_queue.yml"), File.join("config", "iam_permissions", "#{work_queue_name.underscore}_queue.yml")
76
+ template File.join("funktor_config", "iam_permissions", "work_queue.yml"), File.join("funktor_config", "iam_permissions", "#{work_queue_name.underscore}_queue.yml")
77
77
  end
78
78
  end
79
79
 
80
80
  def function_definitions
81
- template File.join("config", "function_definitions", "incoming_job_handler.yml"), File.join("config", "function_definitions", "incoming_job_handler.yml")
81
+ template File.join("funktor_config", "function_definitions", "incoming_job_handler.yml"), File.join("funktor_config", "function_definitions", "incoming_job_handler.yml")
82
82
  queues.each do |queue_details|
83
83
  @work_queue_name = queue_details.keys.first
84
84
  @work_queue_config = queue_details.values.first
85
- template File.join("config", "function_definitions", "work_queue_handler.yml"), File.join("config", "function_definitions", "#{work_queue_name.underscore}_queue_handler.yml")
85
+ template File.join("funktor_config", "function_definitions", "work_queue_handler.yml"), File.join("funktor_config", "function_definitions", "#{work_queue_name.underscore}_queue_handler.yml")
86
86
  end
87
87
  end
88
88
 
@@ -3,7 +3,7 @@ individually: false
3
3
  include:
4
4
  - Gemfile
5
5
  - Gemfile.lock
6
- - config/boot.rb
6
+ - funktor_config/boot.rb
7
7
  - app/**
8
8
  # Evertyting is excluded by default with serverless-ruby-layer, but you could use
9
9
  # the lines below to exlude files that are inside an include path.
@@ -7,10 +7,126 @@ Resources:
7
7
  {
8
8
  "widgets": [
9
9
 
10
+ <% current_y = 0 %>
11
+
12
+ { <% "Funktor Banner" %>
13
+ "height": 3,
14
+ "width": 24,
15
+ "y": <%= current_y %>,
16
+ "x": 0,
17
+ "type": "text",
18
+ "properties": {
19
+ "markdown": "\n# Funktor Auto-generated Dashbaord\n\n This dashboard is auto-generated by Funktor and will be updated as Funktor progresses. If you want to customize this dashboard you should use 'Actions => Save dashbaord as' in the toolbar above to create a new dashboard of your own.\n\n The upper section shows you high level queue and worker stats, the lower sections show more details about all the AWS resources at play."
20
+ }
21
+ },
22
+ <% current_y += 3 %>
23
+
24
+ { <% "Job Duration By Worker" %>
25
+ "height": 6,
26
+ "width": 12,
27
+ "y": <%= current_y %>,
28
+ "x": 12,
29
+ "type": "metric",
30
+ "properties": {
31
+ "metrics": [
32
+ <%- app_worker_names.each do |worker_name| -%>
33
+ [ "<%= app_name %>", "Duration", "WorkerClassName", "<%= worker_name %>" ],
34
+ [ "...", { "stat": "p99" } ]<%= worker_name == app_worker_names.last ? "" : "," %>
35
+ <%- end -%>
36
+ ],
37
+ "view": "timeSeries",
38
+ "stacked": false,
39
+ "region": "us-east-1",
40
+ "stat": "Average",
41
+ "period": 60,
42
+ "title": "Job Duration by Worker"
43
+ }
44
+ },
45
+
46
+ { <% "Processed/Failed Jobs By Worker" %>
47
+ "height": 6,
48
+ "width": 12,
49
+ "y": <%= current_y %>,
50
+ "x": 0,
51
+ "type": "metric",
52
+ "properties": {
53
+ "metrics": [
54
+ <%- app_worker_names.each do |worker_name| -%>
55
+ [ "<%= app_name %>", "processed", "WorkerClassName", "<%= worker_name %>" ],
56
+ [ ".", "failed", ".", "." ]<%= worker_name == app_worker_names.last ? "" : "," %>
57
+ <%- end -%>
58
+ ],
59
+ "view": "timeSeries",
60
+ "stacked": false,
61
+ "region": "us-east-1",
62
+ "title": "Process/Failed Jobs By Worker",
63
+ "period": 60,
64
+ "stat": "Sum"
65
+ }
66
+ },
67
+ <% current_y += 6 %>
68
+ { <% "Job Duration By Queue" %>
69
+ "height": 6,
70
+ "width": 12,
71
+ "y": <%= current_y %>,
72
+ "x": 12,
73
+ "type": "metric",
74
+ "properties": {
75
+ "metrics": [
76
+ <%- queue_names.each do |queue_name| -%>
77
+ [ "<%= app_name %>", "Duration", "Queue", "<%= queue_name %>" ],
78
+ [ "...", { "stat": "p99" } ]<%= queue_name == queue_names.last ? "" : "," %>
79
+ <%- end -%>
80
+ ],
81
+ "view": "timeSeries",
82
+ "stacked": false,
83
+ "region": "us-east-1",
84
+ "stat": "Average",
85
+ "period": 60,
86
+ "title": "Job Duration by Queue"
87
+ }
88
+ },
89
+ { <% "Processed/Failed Jobs By Queue" %>
90
+ "height": 6,
91
+ "width": 12,
92
+ "y": <%= current_y %>,
93
+ "x": 0,
94
+ "type": "metric",
95
+ "properties": {
96
+ "metrics": [
97
+ <%- queue_names.each do |queue_name| -%>
98
+ [ "<%= app_name %>", "processed", "Queue", "<%= queue_name %>" ],
99
+ [ ".", "failed", ".", "." ]<%= queue_name == queue_names.last ? "" : "," %>
100
+ <%- end -%>
101
+ ],
102
+ "view": "timeSeries",
103
+ "stacked": false,
104
+ "region": "us-east-1",
105
+ "title": "Process/Failed Jobs By Queue",
106
+ "period": 60,
107
+ "stat": "Sum"
108
+ }
109
+ },
110
+
111
+
112
+ { <% "Funktor Behind the Scenes Banner" %>
113
+ "height": 3,
114
+ "width": 24,
115
+ "y": <%= current_y %>,
116
+ "x": 0,
117
+ "type": "text",
118
+ "properties": {
119
+ "markdown": "\n# Behind the scenes\n\n The stats below give some insight into the inner workings of the Funktor apparatus."
120
+ }
121
+ },
122
+ <% current_y += 3 %>
123
+
124
+
125
+ <% current_y += 6 %>
10
126
  { <% "Incoming Jobs" %>
11
127
  "height": 3,
12
128
  "width": 6,
13
- "y": 0,
129
+ "y": <%= current_y %>,
14
130
  "x": 0,
15
131
  "type": "text",
16
132
  "properties": {
@@ -20,7 +136,7 @@ Resources:
20
136
  { <% "Incoming Job Queue Messages per minute" %>
21
137
  "height": 3,
22
138
  "width": 3,
23
- "y": 0,
139
+ "y": <%= current_y %>,
24
140
  "x": 6,
25
141
  "type": "metric",
26
142
  "properties": {
@@ -37,7 +153,7 @@ Resources:
37
153
  { <% "Incoming Job Handler Duration" %>
38
154
  "height": 3,
39
155
  "width": 15,
40
- "y": 0,
156
+ "y": <%= current_y %>,
41
157
  "x": 9,
42
158
  "type": "metric",
43
159
  "properties": {
@@ -55,10 +171,12 @@ Resources:
55
171
  }
56
172
  },
57
173
 
174
+
175
+ <% current_y += 3 %>
58
176
  { <% "Incoming Job Queue (Async & scheduled jobs land here first)" %>
59
177
  "height": 6,
60
178
  "width": 9,
61
- "y": 3,
179
+ "y": <%= current_y %>,
62
180
  "x": 0,
63
181
  "type": "metric",
64
182
  "properties": {
@@ -84,7 +202,7 @@ Resources:
84
202
  { <% "Incoming Job Handler Duration in Milliseconds" %>
85
203
  "height": 6,
86
204
  "width": 9,
87
- "y": 3,
205
+ "y": <%= current_y %>,
88
206
  "x": 9,
89
207
  "type": "metric",
90
208
  "properties": {
@@ -104,7 +222,7 @@ Resources:
104
222
  { <% "Incoming Job Handler Error count and success rate (%)" %>
105
223
  "height": 3,
106
224
  "width": 6,
107
- "y": 3,
225
+ "y": <%= current_y %>,
108
226
  "x": 18,
109
227
  "type": "metric",
110
228
  "properties": {
@@ -131,7 +249,7 @@ Resources:
131
249
  { <% "Incoming Job Handler Concurrent Executions" %>
132
250
  "height": 3,
133
251
  "width": 6,
134
- "y": 6,
252
+ "y": <%= current_y + 3 %>,
135
253
  "x": 18,
136
254
  "type": "metric",
137
255
  "properties": {
@@ -149,7 +267,7 @@ Resources:
149
267
 
150
268
 
151
269
 
152
- <% current_y = 9 %>
270
+ <% current_y += 6 %>
153
271
  <%- queue_names.each do |queue_name| -%>
154
272
  { <% "Active Jobs" %>
155
273
  "height": 3,
@@ -300,51 +418,7 @@ Resources:
300
418
  <% current_y += 9 %>
301
419
  <%- end -%>
302
420
 
303
- { <% "Job Duration By Worker" %>
304
- "height": 6,
305
- "width": 24,
306
- "y": <%= current_y %>,
307
- "x": 0,
308
- "type": "metric",
309
- "properties": {
310
- "metrics": [
311
- <%- app_worker_names.each do |worker_name| -%>
312
- [ "<%= app_name %>", "Duration", "WorkerClassName", "<%= worker_name %>" ],
313
- [ "...", { "stat": "p99" } ]<%= worker_name == app_worker_names.last ? "" : "," %>
314
- <%- end -%>
315
- ],
316
- "view": "timeSeries",
317
- "stacked": false,
318
- "region": "us-east-1",
319
- "stat": "Average",
320
- "period": 60,
321
- "title": "Job Duration by Worker"
322
- }
323
- },
324
-
325
- <% current_y += 6 %>
326
- { <% "Processed/Failed Jobs By Worker" %>
327
- "height": 6,
328
- "width": 24,
329
- "y": <%= current_y %>,
330
- "x": 0,
331
- "type": "metric",
332
- "properties": {
333
- "metrics": [
334
- <%- app_worker_names.each do |worker_name| -%>
335
- [ "<%= app_name %>", "processed", "WorkerClassName", "<%= worker_name %>" ],
336
- [ ".", "failed", ".", "." ]<%= worker_name == app_worker_names.last ? "" : "," %>
337
- <%- end -%>
338
- ],
339
- "view": "timeSeries",
340
- "stacked": false,
341
- "region": "us-east-1",
342
- "title": "Process/Failed Jobs By Worker",
343
- "period": 60,
344
- "stat": "Sum"
345
- }
346
- },
347
- <% current_y += 6 %>
421
+
348
422
 
349
423
  { <% "Delayed Jobs" %>
350
424
  "height": 3,
@@ -66,4 +66,4 @@ package:
66
66
  - Gemfile
67
67
  - Gemfile.lock
68
68
  - app/**
69
- - config/**
69
+ - funktor_config/**
@@ -1,7 +1,4 @@
1
- # For this handler we don't need to know about your app, or any of the other gems,
2
- # so instead of doing `require_relative '../config/boog'` we just manually require
3
- # the one gem that we do need.
4
- require 'funktor'
1
+ require_relative '../funktor_config/boot'
5
2
 
6
3
  $handler = Funktor::IncomingJobHandler.new
7
4
 
@@ -1,4 +1,4 @@
1
- require_relative '../config/boot'
1
+ require_relative '../funktor_config/boot'
2
2
 
3
3
  $handler = Funktor::ActiveJobHandler.new
4
4
 
@@ -24,7 +24,7 @@ provider:
24
24
  name: aws
25
25
  runtime: <%= runtime %>
26
26
  lambdaHashingVersion: 20201221
27
- environment: ${file(config/environment.yml)}
27
+ environment: ${file(funktor_config/environment.yml)}
28
28
  versionFunctions: false # Reduces the amount of storage used since all Lambdas together are limited to 75GB
29
29
  iamRoleStatements:
30
30
  <%- all_iam_permissions.each do |iam_permission| -%>
@@ -36,10 +36,10 @@ custom:
36
36
  # Our stage is based on what is passed in when running serverless
37
37
  # commands. Or fallsback to what we have set in the provider section.
38
38
  stage: ${self:provider.stage, 'dev'}
39
- funktor: ${file(config/funktor.yml)}
40
- rubyLayer: ${file(config/ruby_layer.yml)}
39
+ funktor: ${file(funktor_config/funktor.yml)}
40
+ rubyLayer: ${file(funktor_config/ruby_layer.yml)}
41
41
 
42
- package: ${file(config/package.yml)}
42
+ package: ${file(funktor_config/package.yml)}
43
43
 
44
44
  functions:
45
45
  <%- all_function_definitions.each do |function_definition| -%>
@@ -0,0 +1,25 @@
1
+ module Funktor
2
+ module ErrorHandler
3
+ class Logger
4
+ def call(error, context)
5
+ Funktor.logger.warn(Funktor.dump_json(context)) if context
6
+ Funktor.logger.warn("#{error.class.name}: #{error.message}")
7
+ Funktor.logger.warn(error.backtrace.join("\n")) unless error.backtrace.nil?
8
+ end
9
+
10
+ Funktor.error_handlers << Funktor::ErrorHandler::Logger.new
11
+ end
12
+
13
+ def handle_error(error, context = {})
14
+ Funktor.error_handlers.each do |handler|
15
+ begin
16
+ handler.call(error, context)
17
+ rescue => new_error
18
+ Funktor.logger.error "!!! ERROR HANDLER THREW AN ERROR !!!"
19
+ Funktor.logger.error new_error
20
+ Funktor.logger.error new_error.backtrace.join("\n") unless new_error.backtrace.nil?
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ require 'logger'
2
+ module Funktor
3
+ class Logger < ::Logger
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Funktor
2
- VERSION = "0.2.16"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funktor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Green
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sqs
@@ -116,20 +116,20 @@ files:
116
116
  - lib/funktor/cli/init.rb
117
117
  - lib/funktor/cli/templates/Gemfile
118
118
  - lib/funktor/cli/templates/app/workers/hello_worker.rb
119
- - lib/funktor/cli/templates/config/boot.rb
120
- - lib/funktor/cli/templates/config/environment.yml
121
- - lib/funktor/cli/templates/config/function_definitions/incoming_job_handler.yml
122
- - lib/funktor/cli/templates/config/function_definitions/work_queue_handler.yml
123
- - lib/funktor/cli/templates/config/funktor.yml
124
- - lib/funktor/cli/templates/config/iam_permissions/incoming_job_queue.yml
125
- - lib/funktor/cli/templates/config/iam_permissions/ssm.yml
126
- - lib/funktor/cli/templates/config/iam_permissions/work_queue.yml
127
- - lib/funktor/cli/templates/config/package.yml
128
- - lib/funktor/cli/templates/config/resources/cloudwatch_dashboard.yml
129
- - lib/funktor/cli/templates/config/resources/incoming_job_queue.yml
130
- - lib/funktor/cli/templates/config/resources/incoming_job_queue_user.yml
131
- - lib/funktor/cli/templates/config/resources/work_queue.yml
132
- - lib/funktor/cli/templates/config/ruby_layer.yml
119
+ - lib/funktor/cli/templates/funktor_config/boot.rb
120
+ - lib/funktor/cli/templates/funktor_config/environment.yml
121
+ - lib/funktor/cli/templates/funktor_config/function_definitions/incoming_job_handler.yml
122
+ - lib/funktor/cli/templates/funktor_config/function_definitions/work_queue_handler.yml
123
+ - lib/funktor/cli/templates/funktor_config/funktor.yml
124
+ - lib/funktor/cli/templates/funktor_config/iam_permissions/incoming_job_queue.yml
125
+ - lib/funktor/cli/templates/funktor_config/iam_permissions/ssm.yml
126
+ - lib/funktor/cli/templates/funktor_config/iam_permissions/work_queue.yml
127
+ - lib/funktor/cli/templates/funktor_config/package.yml
128
+ - lib/funktor/cli/templates/funktor_config/resources/cloudwatch_dashboard.yml
129
+ - lib/funktor/cli/templates/funktor_config/resources/incoming_job_queue.yml
130
+ - lib/funktor/cli/templates/funktor_config/resources/incoming_job_queue_user.yml
131
+ - lib/funktor/cli/templates/funktor_config/resources/work_queue.yml
132
+ - lib/funktor/cli/templates/funktor_config/ruby_layer.yml
133
133
  - lib/funktor/cli/templates/funktor_init.yml.tt
134
134
  - lib/funktor/cli/templates/gitignore
135
135
  - lib/funktor/cli/templates/lambda_event_handlers/incoming_job_handler.rb
@@ -137,9 +137,11 @@ files:
137
137
  - lib/funktor/cli/templates/package.json
138
138
  - lib/funktor/cli/templates/serverless.yml
139
139
  - lib/funktor/counter.rb
140
+ - lib/funktor/error_handler.rb
140
141
  - lib/funktor/fake_job_queue.rb
141
142
  - lib/funktor/incoming_job_handler.rb
142
143
  - lib/funktor/job.rb
144
+ - lib/funktor/logger.rb
143
145
  - lib/funktor/middleware/metrics.rb
144
146
  - lib/funktor/middleware_chain.rb
145
147
  - lib/funktor/testing.rb
@@ -166,7 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
168
  - !ruby/object:Gem::Version
167
169
  version: '0'
168
170
  requirements: []
169
- rubygems_version: 3.1.4
171
+ rubyforge_project:
172
+ rubygems_version: 2.7.6.3
170
173
  signing_key:
171
174
  specification_version: 4
172
175
  summary: Background processing in AWS Lambda.