villein 0.1.0 → 0.1.1

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: 7f55592c52186b2368ce3cdee25bc3726321ab5b
4
- data.tar.gz: 6f20e0f243da17e2c400d1207069fe796a2022f0
3
+ metadata.gz: b5c615e2b141f002aed95140b94e8df47c7d05f1
4
+ data.tar.gz: e1a88330fa171bf6d9e906f3d6d39eaf4c133fc8
5
5
  SHA512:
6
- metadata.gz: 202eda9a335d1239cb69f025c9239d715ca566cc710e8e2a0239bf42e1b2542b90cfea5948b65b08442770fe373b5abb2c32dbd459ca4018f8a0428f916e4f42
7
- data.tar.gz: 320efc986bf0c185db5ce68dcecb296a5e5a4a9b97204927a61ba42c7b90f02d283150e2af9776d16555493de324dea15bc5b61c28e30f703bcc030ed8c2a5f8
6
+ metadata.gz: ad2473ae38e77bdd1b748ab2a6ee2bec54cb36ca0bbc41121cdd47eddeaadd77abb1b9e328375f8d811843e6e35e3aa2e156dd98533bf819dcfe7e0a637e59bb
7
+ data.tar.gz: d58a938b086694e1f005c9485301328388a07b5ca2a7b7e0897beb6103cf147bb167ae0ac75ac15d5654752138a314902894bd1b8d764ab4fb06a449dbaa8fdf
data/lib/villein/agent.rb CHANGED
@@ -62,9 +62,9 @@ module Villein
62
62
 
63
63
  # Start the serf agent.
64
64
  def start!
65
- raise AlreadyStarted if running?
66
-
67
65
  @pid_lock.synchronize do
66
+ raise AlreadyStarted if running?
67
+
68
68
  start_listening_events
69
69
  start_process
70
70
  start_watchdog
@@ -75,9 +75,9 @@ module Villein
75
75
  # Stop the serf agent.
76
76
  # After +timeout_sec+ seconds elapsed, it will attempt to KILL if the agent is still running.
77
77
  def stop!(timeout_sec = 10)
78
- raise NotRunning unless running?
79
-
80
78
  @pid_lock.synchronize do
79
+ raise NotRunning unless running?
80
+
81
81
  Process.kill(:INT, @pid)
82
82
 
83
83
  stop_watchdog
@@ -99,13 +99,15 @@ module Villein
99
99
  end
100
100
 
101
101
  %w(member_join member_leave member_failed member_update member_reap
102
- user_event query stop event).each do |event|
102
+ user query stop event).each do |event|
103
103
 
104
104
  define_method(:"on_#{event}") do |&block|
105
105
  add_hook(event, block)
106
106
  end
107
107
  end
108
108
 
109
+ alias_method :on_user_event, :on_user
110
+
109
111
  ##
110
112
  # Command line arguments to start serf-agent.
111
113
  def command
data/lib/villein/tags.rb CHANGED
@@ -12,6 +12,10 @@ module Villein
12
12
  if value
13
13
  key = key.to_s
14
14
  value = value.to_s
15
+
16
+ # Don't do anything if same with existing value
17
+ return value if self[key] == value
18
+
15
19
  @client.set_tag(key, value)
16
20
  @tags[key] = value
17
21
  else
@@ -1,3 +1,3 @@
1
1
  module Villein
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/tags_spec.rb CHANGED
@@ -42,10 +42,10 @@ describe Villein::Tags do
42
42
 
43
43
  describe "#update(hash)" do
44
44
  it "sets multiple tags at once" do
45
- expect(parent).to receive(:set_tag).with('a', '1').and_return('1')
46
- expect(parent).to receive(:set_tag).with('b', '2').and_return('2')
45
+ expect(parent).to receive(:set_tag).with('a', '0').and_return('1')
46
+ expect(parent).to receive(:set_tag).with('b', '1').and_return('2')
47
47
 
48
- tags.update(a: 1, b: 2)
48
+ tags.update(a: 0, b: 1)
49
49
  end
50
50
 
51
51
  context "with nil" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: villein
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec