Skip to content

Commit

Permalink
Added stats/leader and stats/self (etcd 0.1.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
stianeikeland committed Oct 13, 2013
1 parent ac5cb60 commit 8d6b537
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions example.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ c.machines (err, val) ->
c.leader (err, val) ->
console.log err, val

# Statistics (leader and self)
c.statsLeader (err, val) -> console.log err, val
c.statsSelf (err, val) -> console.log err, val


## SSL Support

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-etcd",
"version": "0.3.0",
"version": "0.4.0",
"description": "etcd library for node.js",
"licenses": [
{
Expand Down
10 changes: 10 additions & 0 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class Etcd
opt = @_prepareOpts "leader", ""
request.get opt, @_responseHandler callback

# Get statistics about the leader
statsLeader: (callback) ->
opt = @_prepareOpts "stats/leader"
request.get opt, @_responseHandler callback

# Get statistics about the currently connected entity
statsSelf: (callback) ->
opt = @_prepareOpts "stats/self"
request.get opt, @_responseHandler callback

# Get version of etcd
version: (callback) ->
opt = @_prepareOpts "", ""
Expand Down
10 changes: 10 additions & 0 deletions test/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ describe 'Basic functions', () ->
getNock().get('/leader').reply(200, '{"value":"value"}')
etcd.leader checkVal done

describe '#statsLeader()', () ->
it 'should ask etcd for statistics for leader', (done) ->
getNock().get('/v1/stats/leader').reply(200, '{"value":"value"}')
etcd.statsLeader checkVal done

describe '#statsSelf()', () ->
it 'should ask etcd for statistics for connected server', (done) ->
getNock().get('/v1/stats/self').reply(200, '{"value":"value"}')
etcd.statsSelf checkVal done

describe '#version()', () ->
it 'should ask etcd for version', (done) ->
getNock().get('/').reply(200, 'etcd v0.1.0-8-gaad1626')
Expand Down

0 comments on commit 8d6b537

Please sign in to comment.