jflow 0.3.6 → 0.4.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: ee227c0d6cfc06d17a93805bd3c108bef4efe51b
4
- data.tar.gz: e5e0046572c7b25d71bab9e654bc926433739265
3
+ metadata.gz: e2276ad3d9c8655f255cfa1e30aefbc9fa7c600a
4
+ data.tar.gz: 1cd72da5e78de2baaa6b59d7f94e769210218956
5
5
  SHA512:
6
- metadata.gz: 4e5a5a9df63c946880805d2c67815638d9806956e3df6a6c5640a2d1f40d79a0cc6021b9dad4a46f366824b81cfb612046b04d9e2b126b21561ea2cf67468804
7
- data.tar.gz: 365419b044cc4844505b516d442af18ee4565d34b42f79edb6b7e2c2582eca8ae1c8e735a51c43e9a23fc10f127981169bdad5d9624075a55b36c7c4ae078f60
6
+ metadata.gz: 07c8bb0d5c19255d9ffefe88408437f4c3d6ed5eef9d8071d3f637caf12f0eb72a6432a9d37d53600b4aaff6fdd4d6b0296ee30a9cced1cd71e8be9f9a6ca47f
7
+ data.tar.gz: 0af8e2edad69d05aec7772a9d52bdd6f294ea2731976d5e9c0ce02abfc778d1bc838f75f5d52653666f5c1d736249aa40d838b7c335f73ea888f82ac28f0ee18
data/README.md CHANGED
@@ -42,7 +42,8 @@ Class FooActivity
42
42
  default_task_schedule_to_start_timeout: "600",
43
43
  default_task_schedule_to_close_timeout: "600",
44
44
  default_task_start_to_close_timeout: "600",
45
- default_task_heartbeat_timeout: "600"
45
+ default_task_heartbeat_timeout: "600",
46
+ exceptions_to_exclude: [PermanentError]
46
47
  }
47
48
  end
48
49
 
data/jflow.gemspec CHANGED
@@ -6,8 +6,8 @@ require 'jflow/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "jflow"
8
8
  spec.version = JFlow::VERSION
9
- spec.authors = ["Christophe Verbinnen"]
10
- spec.email = ["christophe.verbinnen@lookout.com"]
9
+ spec.authors = ["Christophe Verbinnen","Richard Vorp"]
10
+ spec.email = ["christophe.verbinnen@lookout.com","richard.vorp@lookout.com"]
11
11
 
12
12
  spec.summary = %q{SWF Flow framework for jRuby}
13
13
  spec.description = %q{you know, for flow}
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_runtime_dependency "aws-sdk", "~> 2"
30
30
  spec.add_runtime_dependency "hash_validator", "~> 0.4"
31
+ spec.add_runtime_dependency "jflow_exceptions", "~> 0.1.1"
31
32
 
32
33
  spec.add_development_dependency "bundler", "~> 1.10"
33
34
  spec.add_development_dependency "rake", "~> 10.0"
@@ -2,7 +2,11 @@ module JFlow
2
2
  module Activity
3
3
  class Definition
4
4
 
5
- DEFAULT_OPTIONS = {}
5
+ DEFAULT_OPTIONS = {
6
+ :exceptions_to_exclude => []
7
+ }
8
+
9
+ REGISTRATION_OPTIONS = [:version, :domain, :name, :default_task_list]
6
10
 
7
11
  OPTIONS_VALIDATOR = {
8
12
  :version => "string",
@@ -10,7 +14,8 @@ module JFlow
10
14
  :name => "string",
11
15
  :default_task_list => {
12
16
  :name => "string"
13
- }
17
+ },
18
+ :exceptions_to_exclude => 'array'
14
19
  }
15
20
 
16
21
  attr_reader :options, :klass
@@ -38,7 +43,7 @@ module JFlow
38
43
  end
39
44
 
40
45
  def register_activity
41
- JFlow.configuration.swf_client.register_activity_type(options)
46
+ JFlow.configuration.swf_client.register_activity_type(registration_options)
42
47
  JFlow.configuration.logger.info "Activity #{name} was registered successfuly"
43
48
  end
44
49
 
@@ -77,6 +82,12 @@ module JFlow
77
82
 
78
83
  private
79
84
 
85
+ def registration_options
86
+ REGISTRATION_OPTIONS.each_with_object({}) do |key, hash|
87
+ hash[key] = @options[key]
88
+ end
89
+ end
90
+
80
91
  def validate_activity!
81
92
  validator = HashValidator.validate(@options, OPTIONS_VALIDATOR)
82
93
  raise "Activity #{options[:name]}definition is invalid! #{validator.errors}" unless validator.valid?
@@ -84,4 +95,4 @@ module JFlow
84
95
 
85
96
  end
86
97
  end
87
- end
98
+ end
@@ -16,6 +16,11 @@ module JFlow
16
16
  @map[name][version][:class]
17
17
  end
18
18
 
19
+ def options_for(name, version)
20
+ return nil if !@map.has_key?(name) || !@map[name][version]
21
+ @map[name][version][:options]
22
+ end
23
+
19
24
  end
20
25
  end
21
- end
26
+ end
@@ -43,6 +43,12 @@ module JFlow
43
43
  @klass_value
44
44
  end
45
45
 
46
+ def definition_options
47
+ @definition_options ||= JFlow.configuration.activity_map.options_for(name,version)
48
+ raise "Could not find activity definition for #{name}, #{version}" unless @definition_options
49
+ @definition_options
50
+ end
51
+
46
52
  def method
47
53
  if name.split('.').size > 1
48
54
  method = name.split('.').last
@@ -67,26 +73,30 @@ module JFlow
67
73
  })
68
74
  end
69
75
 
70
-
71
76
  def failed!(exception)
72
77
  log "Task Failed #{exception.message}"
73
78
 
74
79
  reason = truncate(exception.message, MAX_REASON_SIZE)
75
- details = if exception.backtrace
76
- truncate(exception.backtrace.join("\n"), MAX_DETAILS_SIZE)
77
- else
78
- "no stacktrace"
79
- end
80
+
81
+ if retryable?(exception)
82
+ converted_exception = JFlow::Exceptions::Common.new(exception)
83
+ else
84
+ converted_exception = JFlow::Exceptions::Fatal.new(exception)
85
+ end
80
86
 
81
87
  swf_client.respond_activity_task_failed(
82
88
  task_token: token,
83
89
  reason: reason,
84
- details: details
90
+ details: truncate(YAML.dump_stream(converted_exception, exception.backtrace), MAX_DETAILS_SIZE)
85
91
  )
86
92
  end
87
93
 
88
94
  private
89
95
 
96
+ def retryable?(exception)
97
+ !definition_options[:exceptions_to_exclude].include?(exception.class)
98
+ end
99
+
90
100
  def truncate(message, max_length)
91
101
  return message unless message.length > max_length
92
102
 
data/lib/jflow/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JFlow
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/jflow.rb CHANGED
@@ -3,6 +3,7 @@ require "json"
3
3
  require "hash_validator"
4
4
  require 'aws-sdk'
5
5
  require 'logger'
6
+ require 'jflow_exceptions'
6
7
  require "jflow/version"
7
8
  require "jflow/configuration.rb"
8
9
  require "jflow/domain.rb"
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Verbinnen
8
+ - Richard Vorp
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
12
+ date: 2016-04-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: aws-sdk
@@ -38,6 +39,20 @@ dependencies:
38
39
  version: '0.4'
39
40
  prerelease: false
40
41
  type: :runtime
42
+ - !ruby/object:Gem::Dependency
43
+ name: jflow_exceptions
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 0.1.1
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.1.1
54
+ prerelease: false
55
+ type: :runtime
41
56
  - !ruby/object:Gem::Dependency
42
57
  name: bundler
43
58
  version_requirements: !ruby/object:Gem::Requirement
@@ -97,6 +112,7 @@ dependencies:
97
112
  description: you know, for flow
98
113
  email:
99
114
  - christophe.verbinnen@lookout.com
115
+ - richard.vorp@lookout.com
100
116
  executables:
101
117
  - console
102
118
  - jflow_worker