Merge branch 'master' of github.com:grpc/grpc into core_creds_api_change

This commit is contained in:
Julien Boeuf 2015-11-17 15:05:45 -08:00
commit 211b339943
8 changed files with 49 additions and 13 deletions

View File

@ -1,3 +1,4 @@
[![npm](https://img.shields.io/npm/v/grpc.svg)](https://www.npmjs.com/package/grpc)
# Node.js gRPC Library
## Status

View File

@ -82,7 +82,7 @@ bool ParseChannelArgs(Local<Value> args_val,
return false;
}
grpc_channel_args *channel_args = reinterpret_cast<grpc_channel_args*>(
malloc(sizeof(channel_args)));
malloc(sizeof(grpc_channel_args)));
*channel_args_ptr = channel_args;
Local<Object> args_hash = Nan::To<Object>(args_val).ToLocalChecked();
Local<Array> keys = Nan::GetOwnPropertyNames(args_hash).ToLocalChecked();

View File

@ -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;

View File

@ -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
*/
@ -601,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);

View File

@ -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
*/

View File

@ -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
*/
@ -59,7 +68,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 {

View File

@ -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
*/
@ -597,10 +608,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
@ -750,8 +757,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) {

View File

@ -86,7 +86,6 @@ describe('Async functionality', function() {
});
readStream.on('error', function (error) {
console.log(error);
});
});