How to use the thrift.createClient function in thrift

To help you get started, we’ve selected a few thrift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / thrift / test / nodejs / client.js View on Github external
* under the License.
 */

//Client test for the following I/O stack:
//    TBinaryProtocol
//    TFramedTransport
//    TSocket

var assert = require('assert');
var thrift = require('thrift');
var TFramedTransport = require('thrift/transport').TFramedTransport;
var ThriftTest = require('./gen-nodejs/ThriftTest');
var ThriftTestDriver = require('./thrift_test_driver').ThriftTestDriver;

var connection = thrift.createConnection('localhost', 9090, { transport: TFramedTransport} );
var client = thrift.createClient(ThriftTest, connection);

connection.on('error', function(err) {
  assert(false, err);
});

ThriftTestDriver(client, function (status) {
  console.log(status);
  connection.end();
});

// to make it also run on expresso
exports.expressoTest = function() {};
github wadey / node-thrift / examples / client_multitransport.js View on Github external
var thrift = require('thrift'),
    ttransport = require('thrift/transport');

var UserStorage = require('./gen-nodejs/UserStorage'),
    ttypes = require('./gen-nodejs/user_types');

var f_conn = thrift.createConnection('localhost', 9090), // default: framed
    f_client = thrift.createClient(UserStorage, f_conn);
var b_conn = thrift.createConnection('localhost', 9091, {transport: ttransport.TBufferedTransport}),
    b_client = thrift.createClient(UserStorage, b_conn);
var user1 = new ttypes.UserProfile({uid: 1,
                                    name: "Mark Slee",
                                    blurb: "I'll find something to put here."});
var user2 = new ttypes.UserProfile({uid: 2,
                                    name: "Satoshi Tagomori",
                                    blurb: "ok, let's test with buffered transport."});

f_conn.on('error', function(err) {
  console.error("framed:", err);
});

f_client.store(user1, function(err, response) {
  if (err) { console.error(err); return; }

  console.log("stored:", user1.uid, " as ", user1.name);
  b_client.retrieve(user1.uid, function(err, responseUser) {
github omnisci / mapd-connector / src / mapd-con-node-support.js View on Github external
// node client
      if (isNode) {
        const connectOptions = {
          transport: Thrift.TBufferedTransport,
          protocol: Thrift.TJSONProtocol,
          path: '/',
          headers: { Connection: 'close' },
          https: this._protocol[h] === 'https',
        };
        const connection = Thrift.createHttpConnection(
          this._host[h],
          this._port[h],
          connectOptions
        );
        connection.on('error', _logError);
        client = Thrift.createClient(MapD, connection);
      }

      // browser client
      if (hasWindow) {
        const transport = new window.Thrift.Transport(transportUrls[h]);
        const protocol = new window.Thrift.Protocol(transport);
        client = new MapDClient(protocol);
      }

      // sync
      if (!callback) {
        try {
          _sessionId = client.connect(
            this._user[h],
            this._password[h],
            this._dbName[h]
github mozilla / sauropod / srv / storage-thrift.js View on Github external
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
*/

const thrift = require('thrift');
const hbase = require('./gen-nodejs/Hbase');
const ttypes = require('./gen-nodejs/Hbase_types');
const crypto = require('crypto');
const config = require('./configuration').getConfig();

// Our client
config.logger.info("Connecting to thrift server: " + config.storage.host+':'+config.storage.port);
var conn = thrift.createConnection(config.storage.host, config.storage.port);
var client = thrift.createClient(hbase, conn);

const NoSuchColumnFamily = new RegExp(/NoSuchColumnFamilyException/);

function hash(value) {
    // Use Skein insteaf of SHA-1?
    var sha = crypto.createHash('sha1');
    sha.update(value);
    return sha.digest('hex');
}

/* Data layout:
 *
 *  One table per "consumer" of sauropod, identified by the domain name
 *  of the application. This must match the "audience" in the BrowserID
 *  assertion issued.
 *
github tagomoris / shib / examples / hive_methods.js View on Github external
var thrift = require('thrift'),
    ttransport = require('thrift/transport'),
    ThriftHive = require('gen-nodejs/ThriftHive');

var connection = thrift.createConnection("localhost", 10000, {transport: ttransport.TBufferedTransport, timeout: 600*1000}),
    client = thrift.createClient(ThriftHive, connection);

connection.on('error', function(err) {
  console.error(err);
});

connection.addListener("connect", function() {
  client.getClusterStatus(function(err, data){
    console.log("getClusterStatus:", data);
    client.execute('select x, count(*) as cnt from p group by x sort by cnt limit 10', function(err){
      if (err) { console.error("error on execute(): " + err); process.exit(1); }

      client.getQueryPlan(function(err, data){
        console.log("getQueryPlan:", data);
        console.log("queryplan queryAttributes:", data.queries[0].queryAttributes);
        console.log("queryplan stageGraph:", data.queries[0].stageGraph);
        console.log("queryplan stageGraph adjacencyList children:", data.queries[0].stageGraph.adjacencyList[0].children);
github RandyAbernethy / ThriftBook / part3 / nodejs / tradeClient.js View on Github external
var TradeHistory = require('./gen-nodejs/TradeHistory.js');
var tradeUtils = require('./tradeUtils.js');

var intId1 = null;
var intId2 = null;

//Connect to the server and setup a TradeHistory client
var connection = Thrift.createConnection('localhost', 8585, {
  transport: Thrift.TFramedTransport,
  protocol: Thrift.TBinaryProtocol
}).on('error', function(err) {
  console.log(err);
  clearInterval(intId1);
  clearInterval(intId2);
});
var client = Thrift.createClient(TradeHistory, connection);

//Request trade info every 4 seconds and display result
intId1 = setInterval((function() { 
  var counter = 0;
  return function() {
    var fish = ["Halibut", "Salmon", "Ono", "Tuna"][++counter%4];
    client.GetLastSale(fish, function(error, success) {
      if (success) {
        tradeUtils.logTrade(success); 
      }
    });
  };
})(), 4000);

//Request trade list info every 15 seconds and display result
intId2 = setInterval(function() {
github ripple / ripple-data-api / api / library / hbase-thrift / index.js View on Github external
self._connection.on('connect', function() {
    self._retry = 0;
    self.hbase  = thrift.createClient(HBase,self._connection);
    console.log('hbase connected');
  });
github ripple / ripple-data-api / api / library / hbase / hbase-thrift / index.js View on Github external
connection.once('connect', function() {
      this.client = thrift.createClient(HBase, connection);
    });
github mitdbg / modeldb / frontend / util / thrift.js View on Github external
.help('help')
    .argv

var transport = thrift.TFramedTransport;
var protocol = thrift.TBinaryProtocol;

var connection = thrift.createConnection(argv.host, argv.port, {
  transport : transport,
  protocol : protocol
});

connection.on('error', function(err) {
  assert(false, err);
});

var client = thrift.createClient(Service, connection);

module.exports = {
  "client": client,
  "transport": transport
}
github sidorares / mysql-osquery-proxy / proxy.js View on Github external
function osqueryClient() {
  var thrift = require('thrift');
  var ExtensionManager = require('./gen-nodejs/ExtensionManager.js');
  var conn = thrift.createConnection(0, '/var/osquery/osquery.em');
  var client = thrift.createClient(ExtensionManager, conn);
  return client;
}