post merge

This commit is contained in:
Alistair Veitch 2016-02-02 09:43:02 -08:00
parent 0f510b032b
commit 0285389dad
16 changed files with 75 additions and 35 deletions

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -69,7 +69,7 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
return scope.Escape(Nan::Null());
}
size_t length = grpc_byte_buffer_length(buffer);
char *result = reinterpret_cast<char *>(calloc(length, sizeof(char)));
char *result = new char[length];
size_t offset = 0;
grpc_byte_buffer_reader reader;
grpc_byte_buffer_reader_init(&reader, buffer);

View File

@ -112,8 +112,8 @@ void InitCallErrorConstants(Local<Object> exports) {
Nan::Set(exports, Nan::New("callError").ToLocalChecked(), call_error);
Local<Value> OK(Nan::New<Uint32, uint32_t>(GRPC_CALL_OK));
Nan::Set(call_error, Nan::New("OK").ToLocalChecked(), OK);
Local<Value> ERROR(Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR));
Nan::Set(call_error, Nan::New("ERROR").ToLocalChecked(), ERROR);
Local<Value> CALL_ERROR(Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR));
Nan::Set(call_error, Nan::New("ERROR").ToLocalChecked(), CALL_ERROR);
Local<Value> NOT_ON_SERVER(
Nan::New<Uint32, uint32_t>(GRPC_CALL_ERROR_NOT_ON_SERVER));
Nan::Set(call_error, Nan::New("NOT_ON_SERVER").ToLocalChecked(),

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,7 +51,7 @@ var server = require('./src/server.js');
var Metadata = require('./src/metadata.js');
var grpc = require('bindings')('grpc_node');
var grpc = require('./src/grpc_extension');
/**
* Load a gRPC object from an existing ProtoBuf.Reflect object.

View File

@ -76,7 +76,7 @@ function unaryCall(call, callback) {
*/
function streamingCall(call) {
call.on('data', function(value) {
var payload = {body: zeroBuffer(value.repsonse_size)};
var payload = {body: zeroBuffer(value.response_size)};
call.write({payload: payload});
});
call.on('end', function() {

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -99,7 +99,7 @@ exports.runServer = function runServer(call) {
var stats;
switch (request.argtype) {
case 'setup':
server = new BenchmarkServer(request.setup.host, request.setup.port,
server = new BenchmarkServer('[::]', request.setup.port,
request.setup.security_params);
server.start();
stats = server.mark();

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,7 +51,7 @@
var _ = require('lodash');
var grpc = require('bindings')('grpc_node');
var grpc = require('./grpc_extension');
var common = require('./common');

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -61,7 +61,7 @@
'use strict';
var grpc = require('bindings')('grpc_node.node');
var grpc = require('./grpc_extension');
var CallCredentials = grpc.CallCredentials;

40
src/grpc_extension.js Normal file
View File

@ -0,0 +1,40 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
var binary = require('node-pre-gyp');
var path = require('path');
var binding_path =
binary.find(path.resolve(path.join(__dirname, '../../../package.json')));
var binding = require(binding_path);
module.exports = binding;

View File

@ -49,7 +49,7 @@
var _ = require('lodash');
var grpc = require('bindings')('grpc_node');
var grpc = require('./grpc_extension');
/**
* Class for storing metadata. Keys are normalized to lowercase ASCII.

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -51,7 +51,7 @@
var _ = require('lodash');
var grpc = require('bindings')('grpc_node');
var grpc = require('./grpc_extension');
var common = require('./common');

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
'use strict';
var assert = require('assert');
var grpc = require('bindings')('grpc_node');
var grpc = require('../src/grpc_extension');
/**
* Helper function to return an absolute deadline given a relative timeout in

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
'use strict';
var assert = require('assert');
var grpc = require('bindings')('grpc_node');
var grpc = require('../src/grpc_extension');
/**
* This is used for testing functions with multiple asynchronous calls that

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
'use strict';
var assert = require('assert');
var grpc = require('bindings')('grpc_node');
var grpc = require('../src/grpc_extension');
/**
* List of all status names

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,7 +34,7 @@
'use strict';
var assert = require('assert');
var grpc = require('bindings')('grpc_node');
var grpc = require('../src/grpc_extension');
/**
* This is used for testing functions with multiple asynchronous calls that

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,7 +36,7 @@
var assert = require('assert');
var fs = require('fs');
var path = require('path');
var grpc = require('bindings')('grpc_node');
var grpc = require('../src/grpc_extension');
describe('server', function() {
describe('constructor', function() {

View File

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -952,6 +952,7 @@ describe('Call propagation', function() {
describe('Cancellation', function() {
it('With a unary call', function(done) {
done = multiDone(done, 2);
var call;
proxy_impl.unary = function(parent, callback) {
client.unary(parent.request, function(err, value) {
try {
@ -969,12 +970,11 @@ describe('Call propagation', function() {
proxy.start();
var proxy_client = new Client('localhost:' + proxy_port,
grpc.credentials.createInsecure());
var call = proxy_client.unary({}, function(err, value) {
done();
});
call = proxy_client.unary({}, function(err, value) { done(); });
});
it('With a client stream call', function(done) {
done = multiDone(done, 2);
var call;
proxy_impl.clientStream = function(parent, callback) {
client.clientStream(function(err, value) {
try {
@ -992,12 +992,11 @@ describe('Call propagation', function() {
proxy.start();
var proxy_client = new Client('localhost:' + proxy_port,
grpc.credentials.createInsecure());
var call = proxy_client.clientStream(function(err, value) {
done();
});
call = proxy_client.clientStream(function(err, value) { done(); });
});
it('With a server stream call', function(done) {
done = multiDone(done, 2);
var call;
proxy_impl.serverStream = function(parent) {
var child = client.serverStream(parent.request, null,
{parent: parent});
@ -1013,13 +1012,14 @@ describe('Call propagation', function() {
proxy.start();
var proxy_client = new Client('localhost:' + proxy_port,
grpc.credentials.createInsecure());
var call = proxy_client.serverStream({});
call = proxy_client.serverStream({});
call.on('error', function(err) {
done();
});
});
it('With a bidi stream call', function(done) {
done = multiDone(done, 2);
var call;
proxy_impl.bidiStream = function(parent) {
var child = client.bidiStream(null, {parent: parent});
child.on('error', function(err) {
@ -1034,7 +1034,7 @@ describe('Call propagation', function() {
proxy.start();
var proxy_client = new Client('localhost:' + proxy_port,
grpc.credentials.createInsecure());
var call = proxy_client.bidiStream();
call = proxy_client.bidiStream();
call.on('error', function(err) {
done();
});