From c03d669fea45505b030504e4a895d9000ebae60f Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 19 Oct 2015 10:58:10 -0700 Subject: [PATCH 1/6] This is a library. It should not output logs to STDOUT by default --- src/metadata.js | 1 - src/server.js | 4 ---- test/async_test.js | 1 - test/credentials_test.js | 2 +- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/metadata.js b/src/metadata.js index 5c24e46c..183c3ad4 100644 --- a/src/metadata.js +++ b/src/metadata.js @@ -59,7 +59,6 @@ function normalizeKey(key) { function validate(key, value) { if (_.endsWith(key, '-bin')) { if (!(value instanceof Buffer)) { - console.log(value.constructor.toString()); throw new Error('keys that end with \'-bin\' must have Buffer values'); } } else { diff --git a/src/server.js b/src/server.js index a974d593..89e1090c 100644 --- a/src/server.js +++ b/src/server.js @@ -597,10 +597,6 @@ function Server(options) { throw new Error('Server is already running'); } this.started = true; - console.log('Server starting'); - _.each(handlers, function(handler, handler_name) { - console.log('Serving', handler_name); - }); server.start(); /** * Handles the SERVER_RPC_NEW event. If there is a handler associated with diff --git a/test/async_test.js b/test/async_test.js index 6d71ea24..0af63c37 100644 --- a/test/async_test.js +++ b/test/async_test.js @@ -86,7 +86,6 @@ describe('Async functionality', function() { }); readStream.on('error', function (error) { - console.log(error); }); }); diff --git a/test/credentials_test.js b/test/credentials_test.js index 3d0b38fd..3e01b62c 100644 --- a/test/credentials_test.js +++ b/test/credentials_test.js @@ -71,7 +71,7 @@ var fakeSuccessfulGoogleCredentials = { var fakeFailingGoogleCredentials = { getRequestMetadata: function(service_url, callback) { setTimeout(function() { - callback(new Error("Authorization failure")); + callback(new Error('Authorization failure')); }, 0); } }; From 0217e535d894b8f80005d0ff1cf750c4fd20afad Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 19 Oct 2015 16:35:34 -0700 Subject: [PATCH 2/6] Added some file-level comments to Node source files --- src/client.js | 11 +++++++++++ src/common.js | 2 ++ src/metadata.js | 9 +++++++++ src/server.js | 15 +++++++++++++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index 596ea5eb..3cdd5507 100644 --- a/src/client.js +++ b/src/client.js @@ -33,6 +33,17 @@ /** * Client module + * + * This module contains the factory method for creating Client classes, and the + * method calling code for all types of methods. + * + * For example, to create a client and call a method on it: + * + * var proto_obj = grpc.load(proto_file_path); + * var Client = proto_obj.package.subpackage.ServiceName; + * var client = new Client(server_address, client_credentials); + * var call = client.unaryMethod(arguments, callback); + * * @module */ diff --git a/src/common.js b/src/common.js index ebaaa13d..e4fe5a8e 100644 --- a/src/common.js +++ b/src/common.js @@ -32,6 +32,8 @@ */ /** + * This module contains functions that are common to client and server + * code. None of them should be used directly by gRPC users. * @module */ diff --git a/src/metadata.js b/src/metadata.js index 5c24e46c..375c7e98 100644 --- a/src/metadata.js +++ b/src/metadata.js @@ -33,6 +33,15 @@ /** * Metadata module + * + * This module defines the Metadata class, which represents header and trailer + * metadata for gRPC calls. Here is an example of how to use it: + * + * var metadata = new metadata_module.Metadata(); + * metadata.set('key1', 'value1'); + * metadata.add('key1', 'value2'); + * metadata.get('key1') // returns ['value1', 'value2'] + * * @module */ diff --git a/src/server.js b/src/server.js index a974d593..9f9e1898 100644 --- a/src/server.js +++ b/src/server.js @@ -33,6 +33,17 @@ /** * Server module + * + * This module contains all the server code for Node gRPC: both the Server + * class itself and the method handler code for all types of methods. + * + * For example, to create a Server, add a service, and start it: + * + * var server = new server_module.Server(); + * server.addProtoService(protobuf_service_descriptor, service_implementation); + * server.bind('address:port', server_credential); + * server.start(); + * * @module */ @@ -750,8 +761,8 @@ Server.prototype.addProtoService = function(service, implementation) { * Binds the server to the given port, with SSL enabled if creds is given * @param {string} port The port that the server should bind on, in the format * "address:port" - * @param {boolean=} creds Server credential object to be used for SSL. Pass - * nothing for an insecure port + * @param {ServerCredentials=} creds Server credential object to be used for + * SSL. Pass an insecure credentials object for an insecure port. */ Server.prototype.bind = function(port, creds) { if (this.started) { From 4bdba82a93a401b6ed2cc1f8b6e79e5a19553a94 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 22 Oct 2015 09:47:30 -0700 Subject: [PATCH 3/6] Make Node interop client use default roots file path --- interop/interop_client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interop/interop_client.js b/interop/interop_client.js index b5061895..53ffa385 100644 --- a/interop/interop_client.js +++ b/interop/interop_client.js @@ -562,11 +562,11 @@ function runTest(address, host_override, test_case, tls, test_ca, done, extra) { var ca_path; if (test_ca) { ca_path = path.join(__dirname, '../test/data/ca.pem'); + var ca_data = fs.readFileSync(ca_path); + creds = grpc.credentials.createSsl(ca_data); } else { - ca_path = process.env.SSL_CERT_FILE; + creds = grpc.credentials.createSsl(); } - var ca_data = fs.readFileSync(ca_path); - creds = grpc.credentials.createSsl(ca_data); if (host_override) { options['grpc.ssl_target_name_override'] = host_override; options['grpc.default_authority'] = host_override; From 7848ef607d4be74414528cd42ce570f78eb021c4 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 30 Oct 2015 08:47:52 -0700 Subject: [PATCH 4/6] Add npm badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5d89e222..b46b9862 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![npm](https://img.shields.io/npm/v/grpc.svg)](https://www.npmjs.com/package/grpc) # Node.js gRPC Library ## Status From e9af128a7cf0c75eea767639b4787adb06d8e16b Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 6 Nov 2015 10:25:06 -0800 Subject: [PATCH 5/6] Ensure application and Node library user agent strings are together at the beginning --- src/client.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 3cdd5507..d5782678 100644 --- a/src/client.js +++ b/src/client.js @@ -612,7 +612,15 @@ exports.makeClientConstructor = function(methods, serviceName) { if (!options) { options = {}; } - options['grpc.primary_user_agent'] = 'grpc-node/' + version; + /* Append the grpc-node user agent string after the application user agent + * string, and put the combination at the beginning of the user agent string + */ + if (options['grpc.primary_user_agent']) { + options['grpc.primary_user_agent'] += ' '; + } else { + options['grpc.primary_user_agent'] = ''; + } + options['grpc.primary_user_agent'] += 'grpc-node/' + version; /* Private fields use $ as a prefix instead of _ because it is an invalid * prefix of a method name */ this.$channel = new grpc.Channel(address, credentials, options); From d9ed9bc01a794a1d1d767ffcad737c8ef8131320 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 9 Nov 2015 11:04:07 -0800 Subject: [PATCH 6/6] Fixed incorrect type in a malloc in Node extension --- ext/channel.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/channel.cc b/ext/channel.cc index 584a0cf8..c11734d7 100644 --- a/ext/channel.cc +++ b/ext/channel.cc @@ -82,7 +82,7 @@ bool ParseChannelArgs(Local args_val, return false; } grpc_channel_args *channel_args = reinterpret_cast( - malloc(sizeof(channel_args))); + malloc(sizeof(grpc_channel_args))); *channel_args_ptr = channel_args; Local args_hash = Nan::To(args_val).ToLocalChecked(); Local keys = Nan::GetOwnPropertyNames(args_hash).ToLocalChecked();