Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Add Stat Commands #639

Merged
merged 3 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/stats/bitswap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((opts, callback) => {
if (typeof (opts) === 'function') {
callback = opts
opts = {}
}

send({
path: 'stats/bitswap',
qs: opts
}, callback)
})
}
17 changes: 17 additions & 0 deletions src/stats/bw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((opts, callback) => {
if (typeof (opts) === 'function') {
callback = opts
opts = {}
}

send({
path: 'stats/bw',
qs: opts
}, callback)
})
}
13 changes: 13 additions & 0 deletions src/stats/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const moduleConfig = require('../utils/module-config')

module.exports = (arg) => {
const send = moduleConfig(arg)

return {
bitswap: require('./bitswap')(send),
bw: require('./bw')(send),
repo: require('./repo')(send)
}
}
18 changes: 18 additions & 0 deletions src/stats/repo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((opts, callback) => {
if (typeof (opts) === 'function') {
callback = opts
opts = {}
}

send({
path: 'stats/repo',
qs: opts
}, callback)
})
}
1 change: 1 addition & 0 deletions src/utils/load-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function requireCommands () {
ping: require('../ping'),
refs: require('../refs'),
repo: require('../repo'),
stats: require('../stats'),
swarm: require('../swarm'),
pubsub: require('../pubsub'),
update: require('../update'),
Expand Down