journeta 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -160,6 +160,7 @@ module Journeta
160
160
  # the existing record will be updated and given instance #PeerConnection#stop'd.
161
161
  # This prevents pending outbound data from being accidentally dropped.
162
162
  def register_peer(peer)
163
+ putsd "Registering peer: #{peer.uuid}"
163
164
  peer_registry.register(peer)
164
165
  end
165
166
 
@@ -172,4 +173,4 @@ module Journeta
172
173
 
173
174
  end
174
175
 
175
- end
176
+ end
@@ -80,9 +80,9 @@ module Journeta
80
80
  #
81
81
  # Sorry that this is deceptively complicated. It's a design gotcha! :)
82
82
  putsd "Peer #{uuid} has gone away. Deregistering in the background."
83
- Thread.new {
84
- @engine.unregister_peer(self)
85
- }
83
+ Thread.new(self) do |me|
84
+ @engine.unregister_peer(me)
85
+ end
86
86
  end
87
87
  end
88
88
 
@@ -34,29 +34,33 @@ module Journeta
34
34
  loop do
35
35
  # Why 1024? umm.. because it's Thursday!
36
36
  data, meta = socket.recvfrom 1024
37
- Thread.new(data) {
37
+ Thread.new(data, meta) do |data, meta|
38
38
  event = YAML.load(data)
39
39
  if event.uuid != @engine.uuid
40
- m = YAML::load(data)
41
- peer = PeerConnection.new @engine
42
- # Why is this always [2]? Not sure.. they should have returned a hash instead.
43
- peer.ip_address = meta[2]
44
- peer.peer_port = m.peer_port
45
- peer.uuid = m.uuid
46
- peer.version = m.version
47
- peer.groups = m.groups
48
- peer.created_at = peer.updated_at = Time.now
40
+ begin
41
+ m = YAML::load(data)
42
+ peer = PeerConnection.new @engine
43
+ # Why is this always [2]? Not sure.. they should have returned a hash instead.
44
+ peer.ip_address = meta[2]
45
+ peer.peer_port = m.peer_port
46
+ peer.uuid = m.uuid
47
+ peer.version = m.version
48
+ peer.groups = m.groups
49
+ peer.created_at = peer.updated_at = Time.now
49
50
 
50
- # We should not start the #PeerConnection before registering because
51
- # the peer might already be registered. In this case, we'd have wasted a thread,
52
- # so we'll let the registry handle startup (if it happens at all.)
53
- #
54
- # peer.start
51
+ # We should not start the #PeerConnection before registering because
52
+ # the peer might already be registered. In this case, we'd have wasted a thread,
53
+ # so we'll let the registry handle startup (if it happens at all.)
54
+ #
55
+ # peer.start
55
56
 
56
- # TODO validate peer entry is sane before registering it
57
- @engine.register_peer peer
57
+ # TODO validate peer entry is sane before registering it
58
+ @engine.register_peer peer
59
+ rescue => e
60
+ putsd "Error during peer registration: #{e.message}"
61
+ end
58
62
  end
59
- }
63
+ end
60
64
  # putsd "Event received!"
61
65
  end
62
66
  ensure
@@ -2,7 +2,7 @@ module Journeta #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/journeta.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'yaml'
3
3
  require 'set'
4
4
  require 'thread'
5
+ #require 'pp'
5
6
 
6
7
 
7
8
  require 'journeta/logger'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Preston Lee
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-08 00:00:00 -07:00
12
+ date: 2008-10-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency