healthety 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ruby Worker
2
2
 
3
- The Ruby Worker sends JSON wrapped data via UDP packets to a given server at a defined interval.
3
+ The Ruby Worker sends JSON wrapped data via UDP packets to a given host at a defined interval.
4
4
 
5
5
  ## Installation
6
6
 
@@ -14,7 +14,7 @@ $ gem install healthety
14
14
  require "healthety"
15
15
 
16
16
  Healthety.workers do
17
- server "127.0.0.1"
17
+ host "localhost"
18
18
  port 41234
19
19
 
20
20
  worker :load_average do
@@ -30,6 +30,8 @@ Healthety.workers do
30
30
  end
31
31
  ```
32
32
 
33
+ That's all you need to do to define two different workers.
34
+
33
35
  ### Defining helpers
34
36
 
35
37
  If you want to define some helper methods create a new module first. Note the `helpers` method at the end to include your module into the workers. In this case a new file called `connection_helper.rb` contains the MySQL connection handling.
@@ -57,7 +59,7 @@ require "healthety"
57
59
  require "connection_helper"
58
60
 
59
61
  Healthety.workers do
60
- server "127.0.0.1"
62
+ host "localhost"
61
63
  port 41234
62
64
 
63
65
  worker :user_count do
data/healthety.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = "Martin Jagusch"
10
10
  s.email = "m@martinjagusch.com"
11
- s.homepage = "http://github.com/healthety/ruby_worker"
12
- s.description = "The Ruby Worker sends JSON data via UDP packets to a given host."
11
+ s.homepage = "https://github.com/healthety/ruby_worker"
12
+ s.description = "Sends JSON wrapped data via UDP packets to a given host."
13
13
  s.summary = s.description
14
14
 
15
15
  s.add_dependency("json", "~> 1.5.1")
@@ -10,8 +10,8 @@ module Healthety
10
10
  start
11
11
  end
12
12
 
13
- def server(server)
14
- @server = server
13
+ def host(host)
14
+ @host = host
15
15
  end
16
16
 
17
17
  def port(port)
@@ -30,7 +30,7 @@ module Healthety
30
30
 
31
31
  def start
32
32
  puts message
33
- transmission = Transmission.new(@server, @port)
33
+ transmission = Transmission.new(@host, @port)
34
34
 
35
35
  # Catch Ctrl-C and terminate all worker threads.
36
36
  trap("INT") { @threads.map(&:kill) }
@@ -39,7 +39,7 @@ module Healthety
39
39
  @threads << Thread.new do
40
40
  loop do
41
41
  worker.perform
42
- transmission.send(worker.name, worker.value, Time.now.utc)
42
+ transmission.send(worker.name, worker.value)
43
43
  sleep worker.interval
44
44
  end
45
45
  end
@@ -50,7 +50,7 @@ module Healthety
50
50
 
51
51
  def message
52
52
  <<-EOM
53
- => Workers starting to send to #{@server}:#{@port}
53
+ => Workers sending to #{@host}:#{@port}
54
54
  => Ctrl-C to stop
55
55
  EOM
56
56
  end
@@ -3,19 +3,22 @@ require "json"
3
3
 
4
4
  module Healthety
5
5
  class Transmission
6
- def initialize(server, port)
7
- @server = server
6
+ def initialize(host, port)
7
+ @host = host
8
8
  @port = port
9
- @host = Socket.gethostname
9
+ @worker_host = Socket.gethostname
10
10
  @socket = UDPSocket.new
11
11
  end
12
12
 
13
- def send(name, value, created_at)
13
+ def send(name, value)
14
14
  data = {
15
- :name => name, :value => value,
16
- :created_at => created_at, :host => @host
15
+ :value => value,
16
+ :name => name,
17
+ :date => Time.now.to_f,
18
+ :host => @worker_host
17
19
  }.to_json
18
- @socket.send(data, 0, @server, @port)
20
+
21
+ @socket.send(data, 0, @host, @port)
19
22
  $stdout << "#{name}: #{value}\n"
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module Healthety
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -13,7 +13,7 @@ module Healthety
13
13
  it "should start" do
14
14
  expect do
15
15
  Healthety.workers do
16
- server "127.0.0.1"
16
+ host "localhost"
17
17
  port 41234
18
18
 
19
19
  worker :test do
@@ -29,7 +29,7 @@ module Healthety
29
29
 
30
30
  expect do
31
31
  Healthety.workers do
32
- server "127.0.0.1"
32
+ host "localhost"
33
33
  port 41234
34
34
 
35
35
  worker :test do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: healthety
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Martin Jagusch
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-28 00:00:00 Z
13
+ date: 2011-04-29 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 0.9.12
46
46
  type: :development
47
47
  version_requirements: *id003
48
- description: The Ruby Worker sends JSON data via UDP packets to a given host.
48
+ description: Sends JSON wrapped data via UDP packets to a given host.
49
49
  email: m@martinjagusch.com
50
50
  executables: []
51
51
 
@@ -68,7 +68,7 @@ files:
68
68
  - spec/unit/healthety_spec.rb
69
69
  - spec/unit/transmission_spec.rb
70
70
  - spec/unit/worker_spec.rb
71
- homepage: http://github.com/healthety/ruby_worker
71
+ homepage: https://github.com/healthety/ruby_worker
72
72
  licenses: []
73
73
 
74
74
  post_install_message:
@@ -94,7 +94,7 @@ rubyforge_project:
94
94
  rubygems_version: 1.7.2
95
95
  signing_key:
96
96
  specification_version: 3
97
- summary: The Ruby Worker sends JSON data via UDP packets to a given host.
97
+ summary: Sends JSON wrapped data via UDP packets to a given host.
98
98
  test_files:
99
99
  - spec/spec_helper.rb
100
100
  - spec/unit/healthety_spec.rb