Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This file is the stub Node entrypoint that must be spawned by any language which wants to host JS
// components. It should most likely live inside the JS SDK (or another JS package).
const pulumi = require("@pulumi/pulumi");
const grpc = require("grpc");
const runtimeServiceProto = require("@pulumi/pulumi/proto/runtime_grpc_pb.js");
const runtimeProto = require("@pulumi/pulumi/proto/runtime_pb.js");
const gstruct = require("google-protobuf/google/protobuf/struct_pb.js");
const server = new grpc.Server();
server.addService(runtimeServiceProto.RuntimeService, {
construct: construct,
});
server.bind("0.0.0.0:50051", grpc.ServerCredentials.createInsecure());
server.start();
function construct(call, callback) {
const library = require(call.request.getLibrarypath())
const props = pulumi.runtime.deserializeProperties(call.request.getArgs());
const opts = pulumi.runtime.deserializeProperties(call.request.getOpts());
const res = new (library[call.request.getResource()])(call.request.getName(), props, opts);
pulumi.runtime.serializeProperties("inner-construct", res).then(resolved => {
return gstruct.Struct.fromJavaScript(resolved);
}).then(outStruct => {
const reply = new runtimeProto.ConstructResponse();
reply.setOuts(outStruct);
callback(null, reply)
}, err => callback(err));
}
function main() {
const pkg = protoLoader.loadSync(PROTO_PATH);
const proto = grpc.loadPackageDefinition(pkg);
const server = new grpc.Server();
server.addService(proto.demo.NoteService.service, {
create: create,
findById: findById,
find: find,
});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
return server;
}
constructor(serverId: number, useManagedHostHeader = false) {
super("./envoy-grpc-config.yaml", serverId, useManagedHostHeader);
this.server = new grpc.Server();
this.server.addService(Ping.service, {
wrapper: wrapImpl(this.wrapper.bind(this)),
inner: wrapImpl(this.inner.bind(this)),
clientStream: this.clientStream.bind(this),
serverStream: this.serverStream.bind(this),
bidiStream: this.bidiStream.bind(this)
});
this.server.bind(
`${GrpcTestServer.bindHost}:${this.servicePort}`,
grpc.ServerCredentials.createInsecure()
);
}
function main() {
server = new grpc.Server();
server.addService(services.TestServiceService, staticServerDef);
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}
listen () {
this.server.bind(`0.0.0.0:${this.port}`, grpc.ServerCredentials.createInsecure());
console.log(`PaymentService grpc server listening on ${this.port}`);
this.server.start();
}
export default async () => {
const server = new grpc.Server()
const proto: any = getProto('../proto/catalog.proto').coolstore
const healthProto: any = getProto('../proto/health.proto').grpc.health.v1
logger.info(ProductProtoServices)
await server.addService(proto.CatalogService.service, {
...ProductProtoServices
})
await server.addService(healthProto.Health.service, {
...HealthProtoServices
})
server.bind(`${process.env.HOST || '0.0.0.0'}:${process.env.PORT || 5002}`, grpc.ServerCredentials.createInsecure())
server.start()
xLogger.info(`gRPC server running on ${process.env.HOST || '0.0.0.0'}:${process.env.PORT || 5002}.`)
xLogger.info(`Press CTRL-C to stop.`)
}
&& hasAttr(config['server']['message'], 'length')
&& hasAttr(config['server']['message']['length'], 'max')) {
maxMessageSize = config['server']['message']['length']['max'];
}
let server = new grpc.Server({
'grpc.max_send_message_length': maxMessageSize,
'grpc.max_receive_message_length': maxMessageSize
});
let credentials = undefined;
if (hasAttr(config.server, 'ca')
&& hasAttr(config.server, 'key')
&& hasAttr(config.server, 'cert')) {
credentials = grpc.ServerCredentials.createSsl(
fs.readFileSync(config['server']['ca']), [{
cert_chain: fs.readFileSync(config['server']['cert']),
private_key: fs.readFileSync(config['server']['key'])
}], true);
} else {
credentials = grpc.ServerCredentials.createInsecure();
}
server.bind(config['server']['address'], credentials);
return server;
}
function main() {
var server = new grpc.Server();
server.addProtoService(hello_proto.Greeter.service, {sayHello: sayHello, streamOutHello: streamOutHello, echo: echo, concat: concat});
server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}
private static _addTls() {
if (!this.ca || !this.cert || !this.key) {
this._credentials = GRPC.ServerCredentials.createInsecure();
} else {
let ca = FS.readFileSync(this.ca);
let cert = FS.readFileSync(this.cert);
let key = FS.readFileSync(this.key);
this._credentials = GRPC.ServerCredentials.createSsl(ca, [{
cert_chain: cert,
private_key: key
}], true);
}
}
}
public start() {
this.server.addService(
Service.DEFINITION,
new Service.ServicePromiseWrapper(new ServiceImpl())
);
this.server.bind(`0.0.0.0:${this.port}`, grpc.ServerCredentials.createInsecure());
this.server.start();
}