jflow 0.4.5 → 0.5.0

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
  SHA1:
3
- metadata.gz: 76451e88f1fd88254a002eff0dee3aa788e9678c
4
- data.tar.gz: 474dd4aa48a1fb9ce48ec56150c709a0374a5157
3
+ metadata.gz: 960a8f21a063f379ca90a83d8ff0755251d6de18
4
+ data.tar.gz: 1b18e34ab879287ff16008aac79c2d4604688250
5
5
  SHA512:
6
- metadata.gz: 233e7403022056662233f9ffcafd2babacbccb6dd76ce8368b14bd0aaffe964e1cdf933644380e3e63bf564f8897129983f9bcb07319847ea71408357b7ab8c8
7
- data.tar.gz: ca92485f4d4b9c4ea1ae774cef6493428cf908f6401170413ac28a661b0b79f0ed819abf5ea91e438c9f9508d3cd15312d53e8909152ddf2708eb5680a7850ea
6
+ metadata.gz: 4a32307b41cefa618afb109e24d4c45b92ca9a9493d3558c4aa6fcd62306f28a0336e070a96c9344faa329db77eea9ed98ba48422d778dacba35cb579487e4d6
7
+ data.tar.gz: 6051f0c1c0063372303d76c51d136b53554912b42d26ead5847cee611ea6579c995a026a1a96cf4c0436da238fb0a3a277df4aaa5280d10b5f610bf56e49c8c4
data/README.md CHANGED
@@ -71,6 +71,14 @@ Example of a worker.json
71
71
  }
72
72
  ```
73
73
 
74
+ ### Error Handlers
75
+
76
+ You can attach your own error handler for error logging or exception handling by providing a service that responds to `call(exception)`. If you are using Sentry, you can add Raven as error handler:
77
+
78
+ ```ruby
79
+ JFlow.configuration.error_handlers << Proc.new { |e| Raven.capture_exception(e) }
80
+ ```
81
+
74
82
  ## Development
75
83
 
76
84
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -91,6 +91,17 @@ module JFlow
91
91
  )
92
92
  end
93
93
 
94
+ def handle_exception(exception)
95
+ JFlow.configuration.error_handlers.each do |error_handler|
96
+ begin
97
+ error_handler.call(exception)
98
+ rescue => e
99
+ log_error("Error handler failed!")
100
+ log_error(e.backtrace.join("\n")) unless e.backtrace.nil?
101
+ end
102
+ end
103
+ end
104
+
94
105
  private
95
106
 
96
107
  def retryable?(exception)
@@ -113,6 +124,10 @@ module JFlow
113
124
  def log(str)
114
125
  JFlow.configuration.logger.info "[#{Thread.current.object_id}] #{str}"
115
126
  end
127
+
128
+ def log_error(str)
129
+ JFlow.configuration.logger.error "[#{Thread.current.object_id}] #{str}"
130
+ end
116
131
  end
117
132
  end
118
133
  end
@@ -45,6 +45,7 @@ module JFlow
45
45
  Thread.current.set_state(:working)
46
46
  task.run!
47
47
  rescue => exception
48
+ task.handle_exception(exception)
48
49
  task.failed!(exception)
49
50
  end
50
51
  end
@@ -1,7 +1,7 @@
1
1
  module JFlow
2
2
  class Configuration
3
3
 
4
- attr_accessor :swf_client, :load_paths, :logger, :activity_map, :cloudwatch_client
4
+ attr_accessor :swf_client, :load_paths, :logger, :activity_map, :cloudwatch_client, :error_handlers
5
5
 
6
6
  def initialize
7
7
  @swf_client = nil
@@ -9,6 +9,7 @@ module JFlow
9
9
  @load_paths = []
10
10
  @logger = Logger.new(STDOUT)
11
11
  @activity_map = JFlow::Activity::Map.new
12
+ @error_handlers = []
12
13
  end
13
14
  end
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module JFlow
2
- VERSION = "0.4.5"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Verbinnen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-17 00:00:00.000000000 Z
12
+ date: 2016-05-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk