You are viewing a single comment's thread from:

RE: Steem-lib, Intro.

in #steem-lib8 years ago (edited)

how those settings with multiple servers works? Can I set up a threshold after which request will be made to next server as fallback?

PS. Upvoted, Resteemed on Steemit and Stared on Github :)

PS.2. I've just noticed, that you also published guide to this library - to not miss next ones, I also following you now :)

Sort:  

by default, the client will only sent the API calls to one of the connected servers, and it won't fallback to next servers should any error occur.

However, there's a workaround to force an API request to be submitted to all servers.

To use this, you have to call the method in the form of taking arguments as an options-object (as explained in the Guide), and pass in a validating function as 'broadcast' property. The client will sent the APi calls to all servers simultaneously, and callback as soon as it saw a response that pass the validating function... if all failed then the callback will be called with last-received-result.

Example:

var validator =  function (res) {
    // check if it's a valid block
    if (res && res.previous) return true;
    return false;
}

remote.get_block_with({
    blockNum: 960123,
    broadcast: validator,
}, function(err, res) {
    console.log(err, res)
})

thank you for advertising this post @noisy - be happy to upvote @ripplerm over these libraries.
Let me introduce you to http://steemspeak.com where information travels faster, @ripplerm. :)

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.028
BTC 54295.07
ETH 2287.14
USDT 1.00
SBD 2.31