thrift-client-factory
v0.1.1
Published
A factory for creating ready-made using the default configuration thrift clients for nodejs.
Downloads
2
Readme
Thrift Client Factory
A factory for creating ready-made client using the default configuration thrift clients for nodejs.
Getting Started
In order to run tests for this package, some external dependencies need to be installed.
- Install grunt.
$ npm install -g grunt-cli
- Install thrift. Most package managers (brew, chocolately, etc.) have a package for thrift.
- Install npm modules
$ cd {repository-directory}
$ npm install
Running tests
$ grunt test
Usage
Create a Client
// Required node modules
var factory = require("thrift-client-factory");
// Required files
var MyService = require("./gen/MyService");
var hostname = "localhost"; // Arbitrary host
var hostport = 9160; // Arbitrary port
function onError(error) {
console.log(error);
}
var MyClient = factory.create(MyService, hostname, hostport, onError);
Destroy a Client
In a persistent process, if the client/connection is not persisted, then use:
// Thrift creates a reference between the connection object and the client.
// When finished with the client and connection, use:
factory.destroy(MyClient);