Created
December 31, 2010 20:16
-
-
Save wadey/761308 to your computer and use it in GitHub Desktop.
Example node-thrift server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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