Skip to content

Commit

Permalink
Merge branch 'master' into reenable-scala
Browse files Browse the repository at this point in the history
  • Loading branch information
Trisfald authored Jul 27, 2020
2 parents 9d65915 + 0e309bd commit 410cdbb
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for NAME in rust_tonic_mt rust_tonic_st rust_thruster \
java_grpc java_micronaut java_aot \
kotlin_grpc \
scala_akka \
node_grpc_st \
node_grpc_st node_grpcjs_st \
dart_grpc \
crystal_grpc \
swift_grpc_st \
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ docker build --force-rm -f csharp_grpc/Dockerfile -t csharp_grpc_test .
docker build --force-rm -f elixir_grpc/Dockerfile -t elixir_grpc_test .

docker build --force-rm -f java_aot/Dockerfile -t java_aot_test .

docker build --force-rm -f node_grpcjs_st/Dockerfile -t node_grpcjs_st_test .
1 change: 1 addition & 0 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ docker rmi \
lua_grpc_st_test \
node:stretch-slim \
node_grpc_st_test \
node_grpcjs_st_test \
php:zts-buster \
php_grpc_test \
mcr.microsoft.com/dotnet/core/sdk:3.1 \
Expand Down
1 change: 1 addition & 0 deletions node_grpcjs_st/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
9 changes: 9 additions & 0 deletions node_grpcjs_st/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:stretch-slim

WORKDIR /app
COPY node_grpcjs_st /app
COPY proto /app/proto

RUN npm install

ENTRYPOINT [ "node", "greeter_server.js" ]
57 changes: 57 additions & 0 deletions node_grpcjs_st/greeter_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 PROTO_PATH = __dirname + '/proto/helloworld/helloworld.proto';

var grpc = require('@grpc/grpc-js');
var protoLoader = require('@grpc/proto-loader');
var packageDefinition = protoLoader.loadSync(
PROTO_PATH,
{keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true
});
var hello_proto = grpc.loadPackageDefinition(packageDefinition).helloworld;

/**
* Implements the SayHello RPC method.
*/
function sayHello(call, callback) {
callback(null, {message: call.request.name});
}

/**
* Starts an RPC server that receives requests for the Greeter service at the
* sample server port
*/
function main() {
var server = new grpc.Server();
server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
server.bindAsync(
'0.0.0.0:50051',
grpc.ServerCredentials.createInsecure(),
(err, port) => {
process.stdout.write("Server started on 50051");
server.start();
}
);
}

main();
12 changes: 12 additions & 0 deletions node_grpcjs_st/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "grpc-examples",
"version": "0.1.0",
"dependencies": {
"@grpc/proto-loader": "^0.1.0",
"async": "^1.5.2",
"google-protobuf": "^3.0.0",
"@grpc/grpc-js": "^1.1.3",
"lodash": "^4.6.1",
"minimist": "^1.2.0"
}
}

0 comments on commit 410cdbb

Please sign in to comment.