haredo 2.0.6 → 2.0.7

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: a2cff8b9e4c6d2df39d29382b3cc6d1ad1cdf653
4
- data.tar.gz: b51c600b77eadf34286f5a10ac7664f7814c7105
3
+ metadata.gz: 9c008827995252e52b4c23066cb814d27e233bc0
4
+ data.tar.gz: 99b349df834cb737e4bd292aa950d350660c46fb
5
5
  SHA512:
6
- metadata.gz: 1fa6921a853aa13fb1bdae3e3712eca4366d22ecd4039034aa2a6fea77976e70427eefcb6af0b0c49d0562668df48d6597330733ea8e78736f75a6b2b2de073a
7
- data.tar.gz: 96a79dcc5cce9d2d91f3ba198a4940903e3d11409fb98b0ed5e1340a43da1bdaf4dfbc1390be4f3e691becaa3c4c5fbd6aab1786db98fcd110351650b07e0306
6
+ metadata.gz: 2911bbf0b72136f6cc4dff07d1f048714bbfec5de36bd33a9b3838be437442a1d3042ff50ae9f91b33a5feac07bae4704a414dbc5077c1b8bf1b1c726001cdb9
7
+ data.tar.gz: c1fd6b262bea6dd2dc2c73dda042564a24c37e3c9a256bfd2be018f5d3be2b68d094ae5e153048f71668a00e2f9fd0836b0e0f1ec1db0cb93696821d3b723fe6
data/README.md CHANGED
@@ -54,7 +54,7 @@ class Service < HareDo::Peer
54
54
 
55
55
  def serve(msg)
56
56
  data = msg.headers['i'].to_i + 1
57
- send(msg.properties.reply_to, :data => data.to_s)
57
+ reply(msg, :data => data.to_s)
58
58
  end
59
59
 
60
60
  end
@@ -500,6 +500,12 @@ system:
500
500
  user: guest
501
501
  password: guest
502
502
  port: '5672'
503
+ ssl:
504
+ enable: false
505
+ port: '5671'
506
+ tls_cert: '/etc/haredo/ssl/cert.pem'
507
+ tls_key: '/etc/haredo/ssl/key.pem'
508
+ tls_ca: '/etc/haredo/ssl/cacert.pem'
503
509
  daemon:
504
510
  queue:
505
511
  name: 'jujifruit'
@@ -525,6 +531,13 @@ daemon:
525
531
  user: root
526
532
  ```
527
533
 
534
+ Notice the SSL section. You have the option of connecting with or without
535
+ SSL. For SSL, you must include the SSL section and specifically set
536
+ <tt>enable</tt> to true. You must also provide the full path to the client cert,
537
+ key and CA cert you generated for the RabbitMQ broker. See
538
+ http://www.rabbitmq.com/ssl.html and http://rubybunny.info/articles/tls.html for
539
+ more information on using SSL.
540
+
528
541
  ### The Listen Queue
529
542
 
530
543
  The daemon creates a queue using the <tt>queue</tt> entries. The name is given
@@ -14,7 +14,7 @@ module HareDo
14
14
  module Config
15
15
 
16
16
  def loadConfig(file=nil)
17
- @config_file = file || $haredo_default_config_file || HAREDO_DEFAULT_CONFIG_FILE
17
+ @config_file = file || $haredo_default_config_file || HAREDO_DEFAULT_CONFIG_FILE
18
18
  @config = []
19
19
  @config = YAML.load_file(@config_file)
20
20
  @pid_file = $haredo_default_pid_file || HAREDO_DEFAULT_PID_FILE
@@ -2,7 +2,9 @@ require 'syslog'
2
2
  require 'bunny'
3
3
  require 'haredo/version'
4
4
 
5
- def dump_message(msg)
5
+ def dump_message(msg, name)
6
+ puts name if name
7
+
6
8
  if msg.properties != nil
7
9
  puts ' Headers:'
8
10
  msg.properties.each do |k,v|
@@ -97,6 +99,7 @@ class Manager
97
99
  @loaded = {}
98
100
  @config = {}
99
101
  @environment = {}
102
+ @trace = false
100
103
 
101
104
  @module_path_prefix = 'haredo/plugins'
102
105
  end
@@ -154,8 +157,9 @@ end # module Plugins
154
157
 
155
158
  class Peer
156
159
 
157
- attr_reader :queue, :plugins
160
+ attr_reader :queue, :plugins, :mid
158
161
  attr_accessor :timeout, :sleep_interval
162
+ attr_accessor :trace
159
163
 
160
164
  def initialize(name=nil)
161
165
  # Message identifier
@@ -165,6 +169,7 @@ class Peer
165
169
  @timeout = 1.0
166
170
  @sleep_interval = 0.001
167
171
  @receive_queue = {}
172
+ @trace = false
168
173
 
169
174
  # Server attributes
170
175
  # The queue name used for listen()
@@ -205,7 +210,7 @@ class Peer
205
210
  tls_cert = ssl['tls_cert'] || ''
206
211
  tls_key = ssl['tls_key'] || ''
207
212
  tls_ca_certs = [ssl['tls_ca']]
208
-
213
+
209
214
  use_ssl = false
210
215
  if ssl.size > 0 and ssl['enable'] == true
211
216
  use_ssl = true
@@ -285,7 +290,7 @@ class Peer
285
290
 
286
291
  rc = @mid
287
292
  @mid += 1
288
-
293
+
289
294
  if not from.nil?
290
295
  properties[:reply_to] = from
291
296
  else
@@ -294,6 +299,10 @@ class Peer
294
299
 
295
300
  @exchange.publish(data, properties)
296
301
 
302
+ if @trace == true
303
+ dump_message(RabbitMQ::Message.new(headers, properties, data), 'send()')
304
+ end
305
+
297
306
  return rc
298
307
  end
299
308
 
@@ -347,21 +356,23 @@ class Peer
347
356
  if delivery_info != nil
348
357
  msg = RabbitMQ::Message.new(delivery_info, properties, payload)
349
358
 
350
- if msg.headers.has_key?('id')
351
- if mid != nil
352
- if msg.headers['id'] == mid
353
- # Reply flag must be set
354
- if msg.headers['reply'] == 1
355
- return msg
356
- end
357
- end
358
- end
359
-
360
- # Only add to receive queue if we are expecting it
361
- if @receive_queue.has_key?
362
- @receive_queue[msg.headers['id']] = msg
359
+ if @trace == true
360
+ dump_message(msg, 'receive')
361
+ end
362
+
363
+ if mid != nil
364
+ if properties[:correlation_id].to_i == mid.to_i
365
+ # Reply flag must be set
366
+ #if msg.headers['reply'] == 1
367
+ return msg
368
+ #end
363
369
  end
364
370
  end
371
+
372
+ # Only add to receive queue if we are expecting it
373
+ if @receive_queue.has_key?(mid)
374
+ @receive_queue[msg.headers['id']] = msg
375
+ end
365
376
  end
366
377
 
367
378
  if (Time::now.to_f - now) > @timeout
@@ -392,7 +403,10 @@ class Peer
392
403
  headers[:reply] = 1
393
404
  headers[:id] = id.to_i
394
405
 
395
- send(to, :headers => headers, :data => data)
406
+ properties = {}
407
+ properties[:correlation_id] = msg.properties.message_id.to_i
408
+
409
+ send(to, :headers => headers, :properties => properties, :data => data)
396
410
  end
397
411
 
398
412
  # Defined the queue this service will listen on. Assumes a single-instance
@@ -428,7 +442,7 @@ class Peer
428
442
 
429
443
  Syslog.notice('listen()')
430
444
 
431
- listen_queue.subscribe(:block => block, :ack => true) do |info, props, data|
445
+ listen_queue.subscribe(:block => block, :manual_ack => true) do |info, props, data|
432
446
  @channel.acknowledge(info.delivery_tag, false)
433
447
  if serve(RabbitMQ::Message.new(info, props, data)) == false
434
448
  exit 0
@@ -4,8 +4,8 @@ module HareDo
4
4
  VERSION_MAJ = '2'
5
5
  VERSION_MIN = '0'
6
6
  VERSION_CL = ''
7
- VERSION_PL = '6'
8
- VERSION = '2.0.6-1'
9
- RELEASE_DATE = 'Tue, 15 Oct 2013 13:03:56 -0500'
7
+ VERSION_PL = '7'
8
+ VERSION = '2.0.7-1'
9
+ RELEASE_DATE = 'Fri, 07 Nov 2014 13:31:49 -0600'
10
10
 
11
11
  end # module HareDo
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haredo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Owens
8
8
  autorequire:
9
9
  bindir: src/bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: A P2P framework over RabbitMQ
@@ -32,6 +32,8 @@ extensions: []
32
32
  extra_rdoc_files:
33
33
  - README.md
34
34
  files:
35
+ - README.md
36
+ - src/bin/haredo
35
37
  - src/lib/haredo/admin/config.rb
36
38
  - src/lib/haredo/admin/interface.rb
37
39
  - src/lib/haredo/config.rb
@@ -44,8 +46,6 @@ files:
44
46
  - src/lib/haredo/service/config.rb
45
47
  - src/lib/haredo/service/daemon.rb
46
48
  - src/lib/haredo/version.rb
47
- - src/bin/haredo
48
- - README.md
49
49
  homepage: https://github.com/mikeowens/haredo
50
50
  licenses:
51
51
  - MIT
@@ -56,17 +56,17 @@ require_paths:
56
56
  - src/lib
57
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.0.3
69
+ rubygems_version: 2.2.2
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A simple client/server framework using RabbitMQ