Skip to content

Commit

Permalink
expose timeout option, add muxrpcli@3 help
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Apr 5, 2019
1 parent b783f33 commit fce0d52
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

module.exports = {
description: 'gossip ssb messages without replicating the entire feed, aka "Out of Order"',
commands: {
get: {
type: 'async',
description: 'get a message',
args: {
id: {
type: 'MessageId',
description: 'the identity of the message to get',
optional: false
},
timeout: {
type: 'number',
description: 'number of milliseconds to wait for this message, default: 5000, or as set in `config.ooo.timeout`. If timeout is zero it will wait forever.',
optional: true
}
}
}
}
}
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ exports.name = 'ooo'
exports.version = '1.0.0'
exports.manifest = {
stream: 'duplex',
get: 'async'
get: 'async',
help: 'sync'
}
exports.permissions = {
anonymous: {allow: ['stream']}
Expand Down Expand Up @@ -65,7 +66,7 @@ exports.init = function (sbot, config) {

function get (opts, cb) {
var id = isMsg(opts) ? opts : opts.id
var timeout = conf.timeout == null ? 5000 : conf.timeout
var timeout = opts.timeout != null ? opts.timeout : conf.timeout == null ? 5000 : conf.timeout
var timer
if(timeout > 0)
timer = setTimeout(function () {
Expand Down Expand Up @@ -134,7 +135,10 @@ exports.init = function (sbot, config) {
//called by muxrpc, so remote id is set as this.id
return gq.createStream(this.id)
},
get: get
get: get,
help: function () {
return require('./help')
}
}
}

0 comments on commit fce0d52

Please sign in to comment.