Skip to content

Instantly share code, notes, and snippets.

@wadey
Created December 31, 2010 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wadey/761308 to your computer and use it in GitHub Desktop.
Save wadey/761308 to your computer and use it in GitHub Desktop.
Example node-thrift server
var thrift = require('thrift');
var JobExchange = require('./gen-nodejs/JobExchange'),
ttypes = require('./gen-nodejs/scheduler_types');
var server = thrift.createServer(JobExchange, {
insert_job: function(job, callback) {
// job is an instance of ttypes.Job
process.nextTick(function() {
callback(1);
});
},
get_job: function(jid, callback) {
callback(new ttypes.Job());
},
get_all: function(callback) {
callback([new ttypes.Job()]);
}
});
server.listen(9160);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment