0.1.8 • Published 9 years ago

bosrvclient v0.1.8

Weekly downloads
3
License
Apache 2.0
Repository
bitbucket
Last release
9 years ago

BigObject Service client

This is an RPC client for BigObject Service powered by Apache Thrift.

Getting this package

The recommended way to get latest build from this repo is through npm

$ npm install bosrvclient

Basic usage instructions

bosrvclient utilizes HTTP/HTTPS transport and Apache Thrift JSON protocol for delivering and recving data.

To create a connection helper, start by including bosrvclient

var bosrv = require('bosrvclient');
var conn = new bosrv.Connection(<uri_to_bigobject>, <timeout>);

var token = conn.token;
var client = conn.client;

A typical query structure can be layout into the following:

  • Specify and send your query via execute method
  • For methods returning a handle (sha256 string), use cursor helpers to get data back
  • Data retrieved are encoded as JSON string.
client.execute(token, <assoc_stmt>, true, function (err, res) {
    if (err) throw err;
    if (res)
    {
        var rngspec = new bosrv.ttypes.RangeSpec(<start>, <page size>);
        client.cursor_fetch(token, res, rngspec, function (err, data) {
            var data = JSON.parse(data);
            var eol = data[0]; // if eol == -1, then no more data to read
            var rows = data[1];
        });
    }
});

Race conditions with cursor access

While all operations can be interleaved, cursor keep track of access progress through internal data update. To avoid race condition, specify start to in RangeSpec to take hold of indexing at each cursor_fetch.

Handling resource references

We strongly urge you to close the returned resource. While garbage collection is done routinely on the BigObject service, it intended for unexpected termination from client application, hence the garbage collection cycle is kept at a minimal pace.

While it is valid to cache the returned resource handle, make sure your application handles exceptions accordingly.

Exceptions produced by API during runtime

AuthError

produced when providing an invalid authentication token

ServiceError

general mishaps or signs of really bad server state

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.0

9 years ago