Skip to content

Commit

Permalink
Merge pull request #95 from lap1817/feng-pan-nerve
Browse files Browse the repository at this point in the history
[nerve] only mkdir_p in zk_create when the path does not exists
  • Loading branch information
jolynch authored Sep 4, 2017
2 parents 112660b + 205fb95 commit 13bad6f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
nerve (0.8.0)
nerve (0.8.1)
bunny (= 1.1.0)
etcd (~> 0.2.3)
json
Expand Down
3 changes: 2 additions & 1 deletion lib/nerve/reporter/zookeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def zk_delete
end

def zk_create
@zk.mkdir_p(@zk_path)
# only mkdir_p if the path does not exist
@zk.mkdir_p(@zk_path) unless @zk.exists?(@zk_path)
@full_key = @zk.create(@key_prefix, :data => @data, :mode => :ephemeral_sequential)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/nerve/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Nerve
VERSION = "0.8.0"
VERSION = "0.8.1"
end
1 change: 1 addition & 0 deletions spec/lib/nerve/reporter_zookeeper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
it 'deregisters service on exit' do
zk = double("zk")
allow(zk).to receive(:close!)
expect(zk).to receive(:exists?) { "zk_path" }.and_return(false)
expect(zk).to receive(:mkdir_p) { "zk_path" }
expect(zk).to receive(:create) { "full_path" }
expect(zk).to receive(:delete).with("full_path", anything())
Expand Down

0 comments on commit 13bad6f

Please sign in to comment.