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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/jackal.rb +1 -0
- data/lib/jackal/callback.rb +10 -3
- data/lib/jackal/utils/spec/helpers.rb +35 -0
- data/lib/jackal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 325d02d0bc708ec37c2935914fed6563e98dce58
|
4
|
+
data.tar.gz: b0ea2471f5c1b3384244696328fbe1c5d2fec662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0821bf876e9fa4a10fc49b5527f0c95f3fc1d9eaa15a255468ea8a9e229708a100070098d5e5deda6b8bc8dae6fc2ddfaeea45debb243bdabd58003ee824831
|
7
|
+
data.tar.gz: 0910d75f25adad9b539707bd7ab89d543f23e9600204330166ae3489b787663e118b659de193a0bf61c07645d81af095662a529e4ba8f1f5f3a5d3c746f2937b
|
data/CHANGELOG.md
CHANGED
data/lib/jackal.rb
CHANGED
@@ -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|
|
data/lib/jackal/callback.rb
CHANGED
@@ -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
|
data/lib/jackal/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carnivore
|