jackal 0.3.6 → 0.3.8

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
  SHA1:
3
- metadata.gz: 8271606fdf78f46ec9604afc235882cb124e92a8
4
- data.tar.gz: d74a0370fee25281386ed66ae7ad91b59e7bb3a4
3
+ metadata.gz: 325d02d0bc708ec37c2935914fed6563e98dce58
4
+ data.tar.gz: b0ea2471f5c1b3384244696328fbe1c5d2fec662
5
5
  SHA512:
6
- metadata.gz: f1227b853b3e875b4e5a135dbcbc589ab99dc13b4bdaab290b03e93cb7d72b9ab5126c6aa471f5c404fdbe4e23b874c9cf941b86231cc96c6d6cd099b85a6776
7
- data.tar.gz: 1c9222fdaf2aeeb2b70da55f8b20dd7bf5b475a4f66428f011bfadc5199d297ed6f0f630b50d50ee5239ac9c77946c7dfd5e68a760f476da5f9bbbccf25c2bd1
6
+ metadata.gz: f0821bf876e9fa4a10fc49b5527f0c95f3fc1d9eaa15a255468ea8a9e229708a100070098d5e5deda6b8bc8dae6fc2ddfaeea45debb243bdabd58003ee824831
7
+ data.tar.gz: 0910d75f25adad9b539707bd7ab89d543f23e9600204330166ae3489b787663e118b659de193a0bf61c07645d81af095662a529e4ba8f1f5f3a5d3c746f2937b
@@ -1,3 +1,8 @@
1
+ # v0.3.8
2
+ * Expansion of testing helpers
3
+ * Addition of `category` to service registration
4
+ * Set error into payload on failure
5
+
1
6
  # v0.3.6
2
7
  * Fix config library dependency constraints
3
8
 
@@ -19,6 +19,7 @@ module Jackal
19
19
 
20
20
  attribute :name, Symbol, :required => true, :coerce => lambda{|v| v.to_sym}
21
21
  attribute :description, String
22
+ attribute :category, Symbol, :allowed_values => [:full, :modifier, :notifier], :default => :full, :multiple => true
22
23
  attribute :configuration, Configuration, :multiple => true, :default => [], :coerce => lambda{|v|
23
24
  Smash.new(
24
25
  :bogo_multiple => v.map{|name, hsh|
@@ -90,6 +90,7 @@ module Jackal
90
90
  rescue => e
91
91
  error "!!! Unexpected failure encountered -> #{e.class}: #{e}"
92
92
  debug "#{e.class}: #{e}\n#{(e.backtrace || []).join("\n")}"
93
+ payload.set(:error, "#{e.class}: #{e.message}")
93
94
  failed(payload, message, e.message)
94
95
  end
95
96
  end
@@ -101,10 +102,16 @@ module Jackal
101
102
  # @param reason [String]
102
103
  def failed(payload, message, reason='No reason provided')
103
104
  error "Processing of #{message} failed! Reason: #{reason}"
105
+ unless(payload[:error])
106
+ payload.set(:error, reason)
107
+ end
104
108
  message.confirm!
105
109
  dest = destination(:error, payload)
106
110
  source = Carnivore::Supervisor.supervisor[dest]
107
111
  if(source)
112
+ if(formatters)
113
+ apply_formatters!(payload)
114
+ end
108
115
  error "Sending #{message} to error handler: #{source}"
109
116
  source.transmit(payload)
110
117
  else
@@ -132,6 +139,9 @@ module Jackal
132
139
  end
133
140
  source = Carnivore::Supervisor.supervisor[dest]
134
141
  if(source)
142
+ if(formatters)
143
+ apply_formatters!(payload)
144
+ end
135
145
  info "Forwarding payload to output destination... (#{source})"
136
146
  debug "Forwarded payload: #{payload.pretty_inspect}"
137
147
  source.transmit(payload)
@@ -148,9 +158,6 @@ module Jackal
148
158
  # @param message [Carnivore::Message]
149
159
  def job_completed(name, payload, message)
150
160
  info "Processing of message #{message} has completed within this component #{name}"
151
- if(formatters)
152
- apply_formatters!(payload)
153
- end
154
161
  message.confirm!
155
162
  forward(payload)
156
163
  end
@@ -67,3 +67,38 @@ def run_setup(config)
67
67
  source_wait(:setup)
68
68
  runner
69
69
  end
70
+
71
+ # Store callback execution flag in payload to test callback validity
72
+
73
+ # @klass callback class to inject execution tracking
74
+ def track_execution(klass)
75
+ alias_name = :execute_orig
76
+ # Ensure this is called only once within test suite
77
+ return if klass.method_defined?(alias_name)
78
+
79
+ klass.send(:alias_method, alias_name, :execute)
80
+ klass.send(:define_method, :execute) do |message|
81
+ message.args['message']['executed'] = true
82
+ execute_orig(message)
83
+ end
84
+ end
85
+
86
+ # Convenience method to check whether or not callback was executed
87
+
88
+ # @param payload [Smash] payload result from callback execution
89
+ # @return [Boolean] callback execution status
90
+ def callback_executed?(payload)
91
+ payload.get(:executed) == true
92
+ end
93
+
94
+ # Convenience method for sending an actor a payload and waiting for result
95
+
96
+ # @param actor [Carnivore::Source::Actor] actor to receive payload
97
+ # @param payload [Smash] payload to send actor
98
+ # @param wait_time [Numeric] max time to wait for message result (default 1)
99
+ # @return [Smash] payload result
100
+ def transmit_and_wait(actor, payload, wait_time = 1)
101
+ actor.transmit(payload)
102
+ source_wait(wait_time) { !MessageStore.messages.empty? }
103
+ MessageStore.messages.pop
104
+ end
@@ -1,4 +1,4 @@
1
1
  module Jackal
2
2
  # Current library version
3
- VERSION = Gem::Version.new('0.3.6')
3
+ VERSION = Gem::Version.new('0.3.8')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jackal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carnivore