arya-pandemic 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('pandemic', '0.3.6') do |p|
5
+ Echoe.new('pandemic', '0.3.7') do |p|
6
6
  p.description = "Distribute MapReduce to any of the workers and it will spread, like a pandemic."
7
7
  p.url = "https://github.com/arya/pandemic/"
8
8
  p.author = "Arya Asemanfar"
@@ -11,6 +11,7 @@ module Pandemic
11
11
  @connections = []
12
12
  @max_connections = options[:max_connections] || 10
13
13
  @min_connections = options[:min_connections] || 1
14
+ @connect_at_define = options.include?(:connect_at_define) ? options[:connect_at_define] : true
14
15
  @timeout = options[:timeout] || 3
15
16
  end
16
17
 
@@ -36,7 +37,7 @@ module Pandemic
36
37
  end
37
38
  else
38
39
  @create_connection = block
39
- connect
40
+ connect if @connect_at_define
40
41
  end
41
42
  end
42
43
 
@@ -86,7 +86,7 @@ module Pandemic
86
86
  private
87
87
  def initialize_connection_pool
88
88
  return if @connection_pool
89
- @connection_pool = ConnectionPool.new
89
+ @connection_pool = ConnectionPool.new(:connect_at_define => false)
90
90
 
91
91
  @connection_pool.create_connection do
92
92
  connection = nil
@@ -50,17 +50,18 @@ module Pandemic
50
50
  def start
51
51
  raise "You must specify a handler" unless @handler
52
52
 
53
- debug("Listening")
54
53
  @listener = TCPServer.new(@host, @port)
55
54
  @running = true
56
55
  @running_since = Time.now
57
56
 
57
+ debug("Connecting to peers")
58
58
  @peers.values.each { |peer| peer.connect }
59
-
59
+
60
60
  @listener_thread = Thread.new do
61
61
  begin
62
62
  while @running
63
63
  begin
64
+ debug("Listening")
64
65
  conn = @listener.accept
65
66
  Thread.new(conn) { |c| handle_connection(c) }
66
67
  rescue Errno::ECONNABORTED, Errno::EINTR
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pandemic}
5
- s.version = "0.3.6"
5
+ s.version = "0.3.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Arya Asemanfar"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arya-pandemic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar