ganymed-client 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'eventmachine'
1
+ require 'socket'
2
2
 
3
3
  module Ganymed
4
4
  module Client
@@ -6,8 +6,8 @@ module Ganymed
6
6
  ##
7
7
  # An EventMachine Protocol that can send samples to a Ganymed sampler.
8
8
  #
9
- module Sampler
10
- include EM::Deferrable
9
+ class Sampler < UDPSocket
10
+ attr_accessor :origin
11
11
 
12
12
  # Emit a new sample.
13
13
  #
@@ -15,8 +15,8 @@ module Ganymed
15
15
  # @param [String] ns Event namespace.
16
16
  # @param [Fixnum, Float] value Sample value.
17
17
  def emit(ds, ns, value)
18
- data = [ds.to_s, ns, @origin, value.to_f]
19
- send_datagram(data.pack("Z*Z*Z*G"), @host, @port)
18
+ data = [ds.to_s, ns, origin, value.to_f]
19
+ send(data.pack("Z*Z*Z*G"), 0)
20
20
  end
21
21
 
22
22
  # Connect to a Ganymed sampler.
@@ -26,13 +26,10 @@ module Ganymed
26
26
  # @param [String] origin Origin of events. Defaults to the
27
27
  # fully-qualified hostname.
28
28
  def self.connect(host, port, origin=nil)
29
- EM.open_datagram_socket("0.0.0.0", 0, self, host, port, origin)
30
- end
31
-
32
- # @private
33
- def initialize(host, port, origin=nil)
34
- @host, @port = host, port
35
- @origin = origin || ::Socket.gethostbyname(::Socket.gethostname).first
29
+ new.tap do |socket|
30
+ socket.connect(host, port)
31
+ socket.origin = origin || ::Socket.gethostbyname(::Socket.gethostname).first
32
+ end
36
33
  end
37
34
  end
38
35
  end
@@ -1,6 +1,6 @@
1
1
  module Ganymed
2
2
  module Client
3
3
  # @private
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ganymed-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-27 00:00:00.000000000 Z
12
+ date: 2012-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
16
- requirement: &18990080 !ruby/object:Gem::Requirement
16
+ requirement: &19791620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18990080
24
+ version_requirements: *19791620
25
25
  description: Client library for Ganymed
26
26
  email:
27
27
  - bb@xnull.de
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  segments:
63
63
  - 0
64
- hash: -1617282239461546353
64
+ hash: 3452556534310659277
65
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  segments:
72
72
  - 0
73
- hash: -1617282239461546353
73
+ hash: 3452556534310659277
74
74
  requirements: []
75
75
  rubyforge_project:
76
76
  rubygems_version: 1.8.17