nanite 0.4.1.13 → 0.4.1.14
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.
- data/lib/nanite.rb +2 -1
- data/lib/nanite/agent.rb +0 -4
- data/lib/nanite/amqp.rb +15 -2
- data/lib/nanite/cluster.rb +1 -1
- data/lib/nanite/nanite_dispatcher.rb +1 -1
- data/lib/nanite/packets.rb +4 -2
- metadata +2 -2
data/lib/nanite.rb
CHANGED
@@ -5,6 +5,7 @@ require 'json'
|
|
5
5
|
require 'logger'
|
6
6
|
require 'yaml'
|
7
7
|
require 'openssl'
|
8
|
+
require 'fileutils'
|
8
9
|
|
9
10
|
$:.unshift File.dirname(__FILE__)
|
10
11
|
require 'nanite/amqp'
|
@@ -39,7 +40,7 @@ require 'nanite/security/static_certificate_store'
|
|
39
40
|
require 'nanite/serializer'
|
40
41
|
|
41
42
|
module Nanite
|
42
|
-
VERSION = '0.4.1.
|
43
|
+
VERSION = '0.4.1.14' unless defined?(Nanite::VERSION)
|
43
44
|
|
44
45
|
class MapperNotRunning < StandardError; end
|
45
46
|
|
data/lib/nanite/agent.rb
CHANGED
@@ -183,7 +183,6 @@ module Nanite
|
|
183
183
|
Nanite::Log.debug("RECV #{packet.to_s}")
|
184
184
|
case packet
|
185
185
|
when Advertise
|
186
|
-
Nanite::Log.info("RECV #{packet.to_s}") unless Nanite::Log.level == :debug
|
187
186
|
advertise_services
|
188
187
|
when Request, Push
|
189
188
|
if @security && !@security.authorize(packet)
|
@@ -193,14 +192,11 @@ module Nanite
|
|
193
192
|
amq.queue(packet.reply_to, :no_declare => options[:secure]).publish(serializer.dump(r))
|
194
193
|
end
|
195
194
|
else
|
196
|
-
Nanite::Log.info("RECV #{packet.to_s([:from, :tags])}") unless Nanite::Log.level == :debug
|
197
195
|
dispatcher.dispatch(packet)
|
198
196
|
end
|
199
197
|
when Result
|
200
|
-
Nanite::Log.info("RECV #{packet.to_s([])}") unless Nanite::Log.level == :debug
|
201
198
|
@mapper_proxy.handle_result(packet)
|
202
199
|
when IntermediateMessage
|
203
|
-
Nanite::Log.info("RECV #{packet.to_s([])}") unless Nanite::Log.level == :debug
|
204
200
|
@mapper_proxy.handle_intermediate_result(packet)
|
205
201
|
end
|
206
202
|
end
|
data/lib/nanite/amqp.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
class MQ
|
2
2
|
class Queue
|
3
|
+
|
4
|
+
# Monkey patch to add :no_declare => true for new queue objects. See the
|
5
|
+
# explanation for MQ::Exchange#initialize below.
|
6
|
+
def initialize mq, name, opts = {}
|
7
|
+
@mq = mq
|
8
|
+
@opts = opts
|
9
|
+
@bindings ||= {}
|
10
|
+
@mq.queues[@name = name] ||= self
|
11
|
+
@mq.callback{
|
12
|
+
@mq.send Protocol::Queue::Declare.new({ :queue => name,
|
13
|
+
:nowait => true }.merge(opts))
|
14
|
+
} unless opts[:no_declare]
|
15
|
+
end
|
3
16
|
# Asks the broker to redeliver all unacknowledged messages on a
|
4
17
|
# specifieid channel. Zero or more messages may be redelivered.
|
5
18
|
#
|
@@ -48,8 +61,8 @@ module Nanite
|
|
48
61
|
:insist => options[:insist] || false,
|
49
62
|
:retry => options[:retry] || 5,
|
50
63
|
:connection_status => options[:connection_callback] || proc {|event|
|
51
|
-
Nanite::Log.debug("
|
52
|
-
Nanite::Log.debug("
|
64
|
+
Nanite::Log.debug("Connected to MQ") if event == :connected
|
65
|
+
Nanite::Log.debug("Disconnected from MQ") if event == :disconnected
|
53
66
|
}
|
54
67
|
})
|
55
68
|
MQ.new(connection)
|
data/lib/nanite/cluster.rb
CHANGED
@@ -83,7 +83,7 @@ module Nanite
|
|
83
83
|
nanites.update_status(ping.identity, ping.status)
|
84
84
|
reaper.update(ping.identity, agent_timeout + 1) { nanite_timed_out(ping.identity) }
|
85
85
|
else
|
86
|
-
packet = Advertise.new
|
86
|
+
packet = Advertise.new(nil, ping.identity)
|
87
87
|
Nanite::Log.debug("SEND #{packet.to_s} to #{ping.identity}")
|
88
88
|
amq.queue(ping.identity).publish(serializer.dump(packet))
|
89
89
|
end
|
@@ -32,7 +32,7 @@ module Nanite
|
|
32
32
|
callback = lambda do |r|
|
33
33
|
if deliverable.kind_of?(Request)
|
34
34
|
r = Result.new(deliverable.token, deliverable.reply_to, r, identity)
|
35
|
-
Nanite::Log.
|
35
|
+
Nanite::Log.debug("SEND #{r.to_s([])}")
|
36
36
|
amq.queue(deliverable.reply_to, :no_declare => options[:secure]).publish(serializer.dump(r))
|
37
37
|
end
|
38
38
|
r # For unit tests
|
data/lib/nanite/packets.rb
CHANGED
@@ -350,9 +350,11 @@ module Nanite
|
|
350
350
|
# when worker initially comes online to advertise
|
351
351
|
# it's services
|
352
352
|
class Advertise < Packet
|
353
|
-
|
354
|
-
|
353
|
+
attr_accessor :target
|
354
|
+
|
355
|
+
def initialize(size = nil, target = nil)
|
355
356
|
@size = size
|
357
|
+
@target = target
|
356
358
|
end
|
357
359
|
|
358
360
|
def self.json_create(o)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.1.
|
4
|
+
version: 0.4.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Zygmuntowicz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-08 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|