smith 0.5.13.1 → 0.6.1
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 +7 -0
- data/bin/agency +19 -7
- data/bin/pry-smith +11 -0
- data/bin/smithctl +19 -21
- data/lib/smith/acl_compiler.rb +101 -56
- data/lib/smith/acl_parser.rb +75 -0
- data/lib/smith/agent.rb +28 -43
- data/lib/smith/agent_cache.rb +43 -17
- data/lib/smith/agent_monitoring.rb +1 -1
- data/lib/smith/agent_process.rb +148 -53
- data/lib/smith/application/agency.rb +44 -54
- data/lib/smith/bootstrap.rb +31 -17
- data/lib/smith/cache.rb +4 -0
- data/lib/smith/command.rb +1 -3
- data/lib/smith/commands/agency/kill.rb +22 -5
- data/lib/smith/commands/agency/list.rb +9 -4
- data/lib/smith/commands/agency/logger.rb +25 -12
- data/lib/smith/commands/agency/object_count.rb +19 -8
- data/lib/smith/commands/agency/start.rb +7 -10
- data/lib/smith/commands/agency/stop.rb +30 -12
- data/lib/smith/commands/common.rb +1 -1
- data/lib/smith/commands/smithctl/acl.rb +6 -3
- data/lib/smith/commands/smithctl/dump.rb +79 -0
- data/lib/smith/commands/smithctl/firehose.rb +2 -1
- data/lib/smith/commands/smithctl/push.rb +27 -12
- data/lib/smith/commands/smithctl/status.rb +27 -0
- data/lib/smith/config.rb +140 -28
- data/lib/smith/daemon.rb +16 -3
- data/lib/smith/exceptions.rb +6 -3
- data/lib/smith/logger.rb +12 -24
- data/lib/smith/messaging/acl/agent_keepalive.proto +2 -2
- data/lib/smith/messaging/acl/agent_lifecycle.proto +15 -9
- data/lib/smith/messaging/acl/agent_stats.proto +6 -5
- data/lib/smith/messaging/acl/default.rb +2 -7
- data/lib/smith/messaging/acl_type_cache.rb +77 -0
- data/lib/smith/messaging/factory.rb +29 -0
- data/lib/smith/messaging/queue.rb +12 -10
- data/lib/smith/messaging/queue_definition.rb +21 -4
- data/lib/smith/messaging/receiver.rb +55 -62
- data/lib/smith/messaging/requeue.rb +1 -5
- data/lib/smith/messaging/sender.rb +48 -43
- data/lib/smith/messaging/util.rb +0 -10
- data/lib/smith/queue_definitions.rb +7 -4
- data/lib/smith/version.rb +1 -1
- data/lib/smith.rb +57 -56
- metadata +77 -128
- data/lib/smith/messaging/payload.rb +0 -100
data/lib/smith/daemon.rb
CHANGED
@@ -19,11 +19,24 @@ module Smith
|
|
19
19
|
unlink_pid_file
|
20
20
|
|
21
21
|
if @daemonise
|
22
|
-
|
23
|
-
|
22
|
+
fork && exit
|
23
|
+
|
24
|
+
unless Process.setsid
|
25
|
+
raise RuntimeException, 'cannot detach from controlling terminal'
|
26
|
+
end
|
27
|
+
|
24
28
|
$0 = @name
|
29
|
+
|
30
|
+
# Be nice to unmount.
|
31
|
+
Dir.chdir "/"
|
32
|
+
|
33
|
+
STDIN.reopen("/dev/null")
|
34
|
+
STDOUT.reopen("/dev/null")
|
35
|
+
STDERR.reopen(STDOUT)
|
25
36
|
end
|
26
37
|
|
38
|
+
$0 = @name
|
39
|
+
|
27
40
|
@pid.pid = Process.pid
|
28
41
|
logger.debug { "Pid file: #{@pid.filename}" }
|
29
42
|
end
|
@@ -57,7 +70,7 @@ module Smith
|
|
57
70
|
if dir
|
58
71
|
dir
|
59
72
|
else
|
60
|
-
if Smith.config.agency.
|
73
|
+
if Smith.config.agency.to_hash.has_key?(:pid_dir)
|
61
74
|
Smith.config.agency.pid_dir
|
62
75
|
else
|
63
76
|
Dir.tmpdir
|
data/lib/smith/exceptions.rb
CHANGED
@@ -7,9 +7,12 @@ module Smith
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module Messaging
|
10
|
-
class
|
10
|
+
class MessageTimeoutError < RuntimeError; end
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
class
|
13
|
+
module ACL
|
14
|
+
class Error < RuntimeError; end
|
15
|
+
class IncorrectTypeError < Error; end
|
16
|
+
class UnknownError < Error; end
|
14
17
|
end
|
15
18
|
end
|
data/lib/smith/logger.rb
CHANGED
@@ -17,13 +17,10 @@ module Smith
|
|
17
17
|
module Methods
|
18
18
|
protected
|
19
19
|
|
20
|
-
@@__name = 'smith'
|
21
|
-
@@__pattern = Smith::Config.get.logging.default_pattern
|
22
|
-
@@__date_pattern = Smith::Config.get.logging.default_date_pattern
|
23
20
|
@@__level = Smith::Config.get.logging.level
|
24
21
|
@@__trace = Smith::Config.get.logging.trace
|
25
|
-
|
26
|
-
@@
|
22
|
+
|
23
|
+
@@appender = nil
|
27
24
|
|
28
25
|
def log_level(level=nil)
|
29
26
|
if level
|
@@ -37,27 +34,19 @@ module Smith
|
|
37
34
|
Logging.logger.root.level = @@__level
|
38
35
|
end
|
39
36
|
|
40
|
-
def log_appender
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
def log_appender
|
38
|
+
unless @@appender
|
39
|
+
appender_type = Extlib::Inflection.camelize(Config.get.logging.appender.type)
|
40
|
+
pattern_opts = {
|
41
|
+
:pattern => Config.get.logging.default_pattern,
|
42
|
+
:date_pattern => Config.get.logging.default_date_pattern}
|
43
|
+
|
44
|
+
appender_opts = Config.get.logging.appender.clone.merge(:layout => Logging.layouts.pattern(pattern_opts))
|
48
45
|
|
49
|
-
|
50
|
-
case pattern.size
|
51
|
-
when 1
|
52
|
-
@@__pattern = pattern.shift
|
53
|
-
@reload = true
|
54
|
-
when 2
|
55
|
-
@@__pattern = pattern.shift
|
56
|
-
@@__date_pattern = pattern.shift
|
57
|
-
@reload = true
|
46
|
+
@@appender = Logging::Appenders.const_get(appender_type).new('smith', appender_opts)
|
58
47
|
end
|
59
48
|
|
60
|
-
Logging.
|
49
|
+
Logging.logger.root.appenders = @@appender
|
61
50
|
end
|
62
51
|
|
63
52
|
def log_trace(trace)
|
@@ -74,7 +63,6 @@ module Smith
|
|
74
63
|
private
|
75
64
|
|
76
65
|
def __setup
|
77
|
-
self.log_pattern
|
78
66
|
self.log_appender
|
79
67
|
self.log_level
|
80
68
|
@reload = true
|
@@ -1,12 +1,18 @@
|
|
1
1
|
package Smith.ACL;
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
required
|
6
|
-
required
|
7
|
-
optional
|
8
|
-
optional bool
|
9
|
-
optional
|
10
|
-
|
11
|
-
|
3
|
+
message AgentAcknowledgeStart {
|
4
|
+
required string uuid = 1;
|
5
|
+
required int32 pid = 2;
|
6
|
+
required int64 started_at = 3;
|
7
|
+
optional bool singleton = 4;
|
8
|
+
optional bool monitor = 5;
|
9
|
+
optional string metadata = 6;
|
10
|
+
}
|
11
|
+
|
12
|
+
message AgentAcknowledgeStop {
|
13
|
+
required string uuid = 1;
|
14
|
+
}
|
15
|
+
|
16
|
+
message AgentDead {
|
17
|
+
required string uuid = 1;
|
12
18
|
}
|
@@ -6,9 +6,10 @@ message AgentStats {
|
|
6
6
|
required int32 length = 3;
|
7
7
|
}
|
8
8
|
|
9
|
-
required string
|
10
|
-
required
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
required string uuid = 1;
|
10
|
+
required string agent_name = 2;
|
11
|
+
required int32 pid = 3;
|
12
|
+
optional int64 rss = 4;
|
13
|
+
required int64 up_time = 5;
|
14
|
+
repeated QueueStats queues = 6;
|
14
15
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'multi_json'
|
4
4
|
|
5
5
|
module Smith
|
6
6
|
module ACL
|
@@ -15,11 +15,6 @@ module Smith
|
|
15
15
|
@message = message
|
16
16
|
end
|
17
17
|
|
18
|
-
# Always return true. There is no validation.
|
19
|
-
def initialized?
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
18
|
def serialize_to_string
|
24
19
|
Marshal.dump(@message)
|
25
20
|
end
|
@@ -41,7 +36,7 @@ module Smith
|
|
41
36
|
end
|
42
37
|
|
43
38
|
def to_json
|
44
|
-
|
39
|
+
MultiJson.dump(@message)
|
45
40
|
end
|
46
41
|
|
47
42
|
def method_missing(method, args)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require 'extlib'
|
5
|
+
require 'singleton'
|
6
|
+
require 'murmurhash3'
|
7
|
+
|
8
|
+
module Smith
|
9
|
+
class AclTypeCache
|
10
|
+
include Singleton
|
11
|
+
include MurmurHash3
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
clear!
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(type)
|
18
|
+
if @types[type]
|
19
|
+
false
|
20
|
+
else
|
21
|
+
h = to_murmur32(type)
|
22
|
+
@types[type] = h
|
23
|
+
@hashes[h] = type
|
24
|
+
@legacy_types_by_hash[type.to_s.split(/::/)[-1].snake_case] = type
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_by_hash(type)
|
30
|
+
if @hashes[type]
|
31
|
+
@hashes[type]
|
32
|
+
elsif @legacy_types_by_hash[type.to_s]
|
33
|
+
@legacy_types_by_hash[type.to_s]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_by_type(type)
|
38
|
+
@types[type]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Look the key up in the cache. This defaults to the key being the hash.
|
42
|
+
# If :by_type => true is passed in as the second argument then it will
|
43
|
+
# perform the lookup in the type hash.
|
44
|
+
#
|
45
|
+
def include?(key, opts={})
|
46
|
+
if opts[:by_type]
|
47
|
+
!get_by_type(key).nil?
|
48
|
+
else
|
49
|
+
!get_by_hash(key).nil?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Clear the internal hashes.
|
54
|
+
def clear!
|
55
|
+
@types = {}
|
56
|
+
@hashes = {}
|
57
|
+
@legacy_types_by_hash = {}
|
58
|
+
end
|
59
|
+
|
60
|
+
# Dump the type hash
|
61
|
+
def dump_types
|
62
|
+
@types
|
63
|
+
end
|
64
|
+
|
65
|
+
# Dump the hashes hash
|
66
|
+
def dump_hashes
|
67
|
+
@hashes
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# Convert the name to a base 36 murmur hash
|
73
|
+
def to_murmur32(type)
|
74
|
+
V32.murmur3_32_str_hash(type.to_s).to_s(36)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Smith
|
3
|
+
|
4
|
+
module ACL
|
5
|
+
class Factory
|
6
|
+
include Logger
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def create(type, content=nil, &blk)
|
10
|
+
if type.respond_to?(:serialize_to_string)
|
11
|
+
return type
|
12
|
+
else
|
13
|
+
clazz = (type.is_a?(::Protobuf::Message)) ? type : get_clazz(type)
|
14
|
+
|
15
|
+
if blk
|
16
|
+
clazz.new.tap { |m| blk.call(m) }
|
17
|
+
else
|
18
|
+
(content.nil?) ? clazz.new : clazz.new(content)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_clazz(type)
|
24
|
+
type.to_s.split(/::/).inject(Kernel) { |acc, t| acc.const_get(t) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -6,33 +6,35 @@ module Smith
|
|
6
6
|
extend Util
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def messages?(
|
10
|
-
number_of_messages(
|
9
|
+
def messages?(queue_def, &blk)
|
10
|
+
number_of_messages(queue_def) do |n|
|
11
11
|
yield n > 0
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def consumers?(
|
16
|
-
number_of_consumers(
|
15
|
+
def consumers?(queue_def)
|
16
|
+
number_of_consumers(queue_def) do |n|
|
17
17
|
yield n > 0
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def number_of_consumers(
|
22
|
-
status(
|
21
|
+
def number_of_consumers(queue_def)
|
22
|
+
status(queue_def) do |_, number_consumers|
|
23
23
|
yield number_consumers
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def number_of_messages(
|
28
|
-
status(
|
27
|
+
def number_of_messages(queue_def)
|
28
|
+
status(queue_def) do |number_messages, _|
|
29
29
|
yield number_messages
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def status(
|
33
|
+
def status(queue_def)
|
34
34
|
open_channel do |channel, ok|
|
35
|
-
|
35
|
+
|
36
|
+
queue_def = queue_def.is_a?(QueueDefinition) ? queue_def : QueueDefinition.new(queue_def, :passive => true)
|
37
|
+
channel.queue(*queue_def.to_a).status do |number_messages, number_consumers|
|
36
38
|
yield number_messages, number_consumers
|
37
39
|
channel.close
|
38
40
|
end
|
@@ -3,16 +3,33 @@
|
|
3
3
|
module Smith
|
4
4
|
class QueueDefinition
|
5
5
|
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :options
|
7
7
|
|
8
8
|
def initialize(name, options)
|
9
|
-
@
|
9
|
+
@normalised_queue = "#{Smith.config.smith.namespace}.#{name}"
|
10
|
+
@denormalised_queue = "#{name}"
|
10
11
|
@options = options
|
11
12
|
end
|
12
13
|
|
14
|
+
def denormalise
|
15
|
+
@denormalised_queue
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
@normalised_queue
|
20
|
+
end
|
21
|
+
|
22
|
+
def normalise
|
23
|
+
@normalised_queue
|
24
|
+
end
|
25
|
+
|
13
26
|
# to_a is defined to make the splat operator work.
|
14
|
-
def to_a
|
15
|
-
return @
|
27
|
+
def to_a
|
28
|
+
return @normalised_queue, @options
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
"<#{self.class}: #{@denormalised_queue}, #{@options.inspect}>"
|
16
33
|
end
|
17
34
|
end
|
18
35
|
end
|
@@ -10,26 +10,25 @@ module Smith
|
|
10
10
|
include Logger
|
11
11
|
include Util
|
12
12
|
|
13
|
-
|
13
|
+
def initialize(queue_def, opts={}, &blk)
|
14
14
|
|
15
|
-
|
15
|
+
# This is for backward compatibility.
|
16
|
+
@queue_def = queue_def.is_a?(QueueDefinition) ? queue_def : QueueDefinition.new(queue_def, opts)
|
16
17
|
|
17
|
-
@
|
18
|
-
|
19
|
-
@normalised_queue_name = normalise(@queue_name)
|
18
|
+
@acl_type_cache = AclTypeCache.instance
|
20
19
|
|
21
20
|
@foo_options = {
|
22
|
-
:auto_ack => option_or_default(
|
23
|
-
:threading => option_or_default(
|
21
|
+
:auto_ack => option_or_default(@queue_def.options, :auto_ack, true),
|
22
|
+
:threading => option_or_default(@queue_def.options, :threading, false)}
|
24
23
|
|
25
|
-
@payload_type = option_or_default(
|
24
|
+
@payload_type = Array(option_or_default(@queue_def.options, :type, []))
|
26
25
|
|
27
|
-
prefetch = option_or_default(
|
26
|
+
prefetch = option_or_default(@queue_def.options, :prefetch, Smith.config.agent.prefetch)
|
28
27
|
|
29
|
-
@options = AmqpOptions.new(
|
30
|
-
@options.routing_key = @
|
28
|
+
@options = AmqpOptions.new(@queue_def.options)
|
29
|
+
@options.routing_key = @queue_def.normalise
|
31
30
|
|
32
|
-
@message_counter = MessageCounter.new(@
|
31
|
+
@message_counter = MessageCounter.new(@queue_def.denormalise)
|
33
32
|
|
34
33
|
@channel_completion = EM::Completion.new
|
35
34
|
@queue_completion = EM::Completion.new
|
@@ -40,55 +39,38 @@ module Smith
|
|
40
39
|
|
41
40
|
open_channel(:prefetch => prefetch) do |channel|
|
42
41
|
@channel_completion.succeed(channel)
|
43
|
-
channel.direct(@
|
42
|
+
channel.direct(@queue_def.normalise, @options.exchange) do |exchange|
|
44
43
|
@exchange_completion.succeed(exchange)
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
open_channel(:prefetch => prefetch) do |channel|
|
49
|
-
channel.queue(@
|
48
|
+
channel.queue(@queue_def.normalise, @options.queue) do |queue|
|
50
49
|
@exchange_completion.completion do |exchange|
|
51
|
-
queue.bind(exchange, :routing_key => @
|
50
|
+
queue.bind(exchange, :routing_key => @queue_def.normalise)
|
52
51
|
@queue_completion.succeed(queue)
|
53
52
|
@requeue_options_completion.succeed(:exchange => exchange, :queue => queue)
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
|
-
start_garbage_collection
|
59
|
-
|
60
57
|
blk.call(self) if blk
|
61
58
|
end
|
62
59
|
|
63
|
-
def start_garbage_collection
|
64
|
-
logger.debug { "Starting the garbage collector." }
|
65
|
-
EM.add_periodic_timer(5) do
|
66
|
-
@reply_queues.each do |queue_name,queue|
|
67
|
-
queue.status do |number_of_messages, number_of_consumers|
|
68
|
-
if number_of_messages == 0 && number_of_consumers == 0
|
69
|
-
queue.delete do |delete_ok|
|
70
|
-
@reply_queues.delete(queue_name)
|
71
|
-
logger.debug { "Unused reply queue deleted: #{queue_name}" }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
60
|
def ack(multiple=false)
|
80
61
|
@channel_completion.completion {|channel| channel.ack(multiple) }
|
81
62
|
end
|
82
63
|
|
83
|
-
private :start_garbage_collection
|
84
|
-
|
85
64
|
def setup_reply_queue(reply_queue_name, &blk)
|
86
65
|
if @reply_queues[reply_queue_name]
|
87
66
|
blk.call(@reply_queues[reply_queue_name])
|
88
67
|
else
|
89
68
|
@exchange_completion.completion do |exchange|
|
90
69
|
logger.debug { "Attaching to reply queue: #{reply_queue_name}" }
|
91
|
-
|
70
|
+
|
71
|
+
queue_def = QueueDefinition.new(reply_queue_name, :auto_delete => true, :immediate => true, :mandatory => true, :durable => false)
|
72
|
+
|
73
|
+
Smith::Messaging::Sender.new(queue_def) do |sender|
|
92
74
|
@reply_queues[reply_queue_name] = sender
|
93
75
|
blk.call(sender)
|
94
76
|
end
|
@@ -104,21 +86,27 @@ module Smith
|
|
104
86
|
@requeue_options_completion.completion do |requeue_options|
|
105
87
|
if !queue.subscribed?
|
106
88
|
opts = @options.subscribe
|
107
|
-
logger.debug { "Subscribing to: [queue]:#{@
|
89
|
+
logger.debug { "Subscribing to: [queue]:#{@queue_def.denormalise} [options]:#{opts}" }
|
108
90
|
queue.subscribe(opts) do |metadata,payload|
|
109
91
|
if payload
|
110
92
|
on_message(metadata, payload, requeue_options, &blk)
|
111
93
|
else
|
112
|
-
logger.verbose { "Received null message on: #{@
|
94
|
+
logger.verbose { "Received null message on: #{@queue_def.denormalise} [options]:#{opts}" }
|
113
95
|
end
|
114
96
|
end
|
115
97
|
else
|
116
|
-
logger.error { "Queue is already subscribed too. Not listening on: #{@
|
98
|
+
logger.error { "Queue is already subscribed too. Not listening on: #{@queue_def.denormalise}" }
|
117
99
|
end
|
118
100
|
end
|
119
101
|
end
|
120
102
|
end
|
121
103
|
|
104
|
+
def unsubscribe(&blk)
|
105
|
+
@queue_completion.completion do |queue|
|
106
|
+
queue.unsubscribe(&blk)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
122
110
|
# pops a message off the queue and passes the headers and payload
|
123
111
|
# into the block. +pop+ will automatically acknowledge the message
|
124
112
|
# unless the options sets :ack to false.
|
@@ -146,7 +134,7 @@ module Smith
|
|
146
134
|
end
|
147
135
|
|
148
136
|
def on_message(metadata, payload, requeue_options, &blk)
|
149
|
-
if @payload_type.empty? || @payload_type.include?(metadata.type
|
137
|
+
if @payload_type.empty? || @payload_type.include?(@acl_type_cache.get_by_hash(metadata.type))
|
150
138
|
@message_counter.increment_counter
|
151
139
|
if metadata.reply_to
|
152
140
|
setup_reply_queue(metadata.reply_to) do |queue|
|
@@ -156,32 +144,31 @@ module Smith
|
|
156
144
|
Foo.new(metadata, payload, @foo_options, requeue_options, &blk)
|
157
145
|
end
|
158
146
|
else
|
159
|
-
|
147
|
+
allowable_acls = @payload_type.join(", ")
|
148
|
+
received_acl = @acl_type_cache.get_by_hash(metadata.type)
|
149
|
+
raise ACL::IncorrectTypeError, "Received ACL: #{received_acl} on queue: #{@queue_def.denormalise}. This queue can only accept the following ACLs: #{allowable_acls}"
|
160
150
|
end
|
161
151
|
end
|
162
152
|
|
163
153
|
private :on_message
|
164
154
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
# exchange.delete do
|
170
|
-
# @channel_completion.completion do |channel|
|
171
|
-
# channel.close(&blk)
|
172
|
-
# end
|
173
|
-
# end
|
174
|
-
# end
|
175
|
-
# end
|
176
|
-
# end
|
177
|
-
# end
|
178
|
-
|
179
|
-
|
180
|
-
# I've a feeling this should be replaced by the above code.
|
181
|
-
# TODO Check this is correct.
|
155
|
+
def queue_name
|
156
|
+
@queue_def.denormalise
|
157
|
+
end
|
158
|
+
|
182
159
|
def delete(&blk)
|
183
|
-
@
|
184
|
-
queue
|
160
|
+
@exchange_completion.completion do |exchange|
|
161
|
+
@queue_completion.completion do |queue|
|
162
|
+
@channel_completion.completion do |channel|
|
163
|
+
queue.unbind(exchange) do
|
164
|
+
queue.delete do
|
165
|
+
exchange.delete do
|
166
|
+
channel.close(&blk)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
185
172
|
end
|
186
173
|
end
|
187
174
|
|
@@ -212,7 +199,6 @@ module Smith
|
|
212
199
|
end
|
213
200
|
end
|
214
201
|
|
215
|
-
|
216
202
|
class Foo
|
217
203
|
include Smith::Logger
|
218
204
|
|
@@ -223,8 +209,15 @@ module Smith
|
|
223
209
|
@reply_queue = opts[:reply_queue]
|
224
210
|
@requeue_opts = requeue_opts
|
225
211
|
|
212
|
+
@acl_type_cache = AclTypeCache.instance
|
213
|
+
|
226
214
|
@time = Time.now
|
227
|
-
|
215
|
+
|
216
|
+
# TODO add some better error checking/diagnostics.
|
217
|
+
clazz = @acl_type_cache.get_by_hash(metadata.type)
|
218
|
+
raise ACL::UnknownError, "Unknown ACL: #{metadata.type}" if clazz.nil?
|
219
|
+
|
220
|
+
@message = clazz.new.parse_from_string(data)
|
228
221
|
|
229
222
|
if opts[:threading]
|
230
223
|
EM.defer do
|
@@ -38,7 +38,7 @@ module Smith
|
|
38
38
|
logger.verbose { "Requeuing to: #{@queue.name}. [options]: #{opts}" }
|
39
39
|
logger.verbose { "Requeuing to: #{@queue.name}. [message]: #{@message}" }
|
40
40
|
|
41
|
-
@exchange.publish(ACL::
|
41
|
+
@exchange.publish(ACL::Factory.create(@metadata.type, @message), opts)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -82,10 +82,6 @@ module Smith
|
|
82
82
|
def linear_strategy(delay)
|
83
83
|
delay * (current_requeue_number + 1)
|
84
84
|
end
|
85
|
-
|
86
|
-
def denormalise(name)
|
87
|
-
name.gsub(/^#{Regexp.escape(Smith.config.smith.namespace)}./, '')
|
88
|
-
end
|
89
85
|
end
|
90
86
|
end
|
91
87
|
end
|