Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).then(() => {
// after inital all and start thrift server
self._server = thrift.createServer(self._innerThriftProcessor, self._innerHandler, self._serverOptions || {});
self._server.listen(self._port);
// inital service
if (self._custom) {
return self._publish(options.thrift.alias,
{host: self._host, port: self._port, actions: false},
utils.TTL);
} else {
self.add = self._add;
// inital service
return self._add(options.services);
}
}).then(() => {
// emit listening
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var thrift = require('thrift');
var Thrift = thrift.Thrift;
var ttransport = require('transport');
var ThriftTest = require('./gen-nodejs/ThriftTest'),
ttypes = require('./gen-nodejs/ThriftTest_types');
var server = thrift.createServer(ThriftTest, {
testVoid: function(result) {
console.log('testVoid()');
result(null);
},
testString: function(thing, result) {
console.log('testString(\'' + thing + '\')');
result(null, thing);
},
testByte: function(thing, result) {
console.log('testByte(' + thing + ')');
result(null, thing);
},
testI32: function(thing, result) {
var thrift = require("thrift");
var Donkey = require('./gen-nodejs/Donkey');
var ttypes = require('./gen-nodejs/donkey_types');
var server = thrift.createServer(Donkey, {
search:
function(q, result) {
console.log("@thrift server search: "+JSON.stringify(q));
var now=new Date();
var time=now.toTimeString()+" ";
var data = [];
if(q.url=="error"){
var ex=new ttypes.Exception();
ex.what=0;
ex.why="intended error";
result(ex);
}else{
for(i=0;i<500;i++){
var hit=new ttypes.Hit();
hit.key=time+i;
var UserStorage = require('./gen-nodejs/UserStorage'),
ttypes = require('./gen-nodejs/user_types');
var users = {};
var store = function(user, result) {
console.log("stored:", user.uid);
users[user.uid] = user;
result(null);
};
var retrieve = function(uid, result) {
console.log("retrieved:", uid);
result(null, users[uid]);
};
var server_framed = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
});
server_framed.listen(9090);
var server_buffered = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
}, {transport: ttransport.TBufferedTransport});
server_buffered.listen(9091);
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var thrift = require("thrift");
var Calculator = require("./gen-nodejs/Calculator");
var ttypes = require("./gen-nodejs/tutorial_types");
var SharedStruct = require("./gen-nodejs/shared_types").SharedStruct;
var data = {};
var server = thrift.createServer(Calculator, {
ping: function(result) {
console.log("ping()");
result(null);
},
add: function(n1, n2, result) {
console.log("add(", n1, ",", n2, ")");
result(null, n1 + n2);
},
calculate: function(logid, work, result) {
console.log("calculate(", logid, ",", work, ")");
var val = 0;
if (work.op == ttypes.Operation.ADD) {
val = work.num1 + work.num2;
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var thrift = require('thrift');
var UserStorage = require('./gen-nodejs/UserStorage.js'),
ttypes = require('./gen-nodejs/user_types');
var users = {};
var server = thrift.createServer(UserStorage, {
store: function(user, success) {
console.log("server stored:", user.uid);
users[user.uid] = user;
success();
},
retrieve: function(uid, success) {
console.log("server retrieved:", uid);
success(users[uid]);
},
});
server.listen(9090);
newdata = "";
for (var i=0; i < bytes; i++) {
newdata.concat("x");
}
callback(null, newdata);
},
echo : function(data, callback) {
callback(null, data);
},
add : function(a, b, callback) {
callback(null, a + b);
}
};
if (options.server == "multiplex") {
var app = thrift.createServer(
LoadTest,
methods,
{transport: ttransport.TFramedTransport}
);
app.on('error', function(error) {
console.warn(error);
});
app.listen(options.port, '::');
} else if (options.server == "cpp") {
var server = new ThriftServer(LoadTest, methods);
if (options.ssl_cert && options.ssl_key) {
var config = new ThriftServer.SSLConfig();
config.certPath = options.ssl_cert;
config.keyPath = options.ssl_key;
if (options.ticket_file) {
config.ticketFilePath = options.ticket_file;
var store = function(user, result) {
console.log("stored:", user.uid);
users[user.uid] = user;
result(null);
};
var retrieve = function(uid, result) {
console.log("retrieved:", uid);
result(null, users[uid]);
};
var server_framed = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
});
server_framed.listen(9090);
var server_buffered = thrift.createServer(UserStorage, {
store: store,
retrieve: retrieve
}, {transport: ttransport.TBufferedTransport});
server_buffered.listen(9091);
module.exports = function(settings) {
var server = thrift.createServer(Address, module.exports.methods);
server.listen(settings.port);
};
},
fetchThing(): CommonStruct {
return new CommonStruct({
code: new Code({ status: 5 }),
value: 'test',
})
},
fetchUnion(): CommonUnion {
return new CommonUnion({ option1: 'test' })
},
broken(): void {
throw new Error(`Yeah, this didn't work`)
},
}
return thrift.createServer(
Calculator.Processor,
impl,
{
transport: thrift.TFramedTransport,
},
)
}