mirror of https://github.com/grpc/grpc-node.git
commit
78ac67af24
|
|
@ -270,6 +270,10 @@ NAN_METHOD(Channel::GetTarget) {
|
||||||
"getTarget can only be called on Channel objects");
|
"getTarget can only be called on Channel objects");
|
||||||
}
|
}
|
||||||
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
||||||
|
if (channel->wrapped_channel == NULL) {
|
||||||
|
return Nan::ThrowError(
|
||||||
|
"Cannot call getTarget on a closed Channel");
|
||||||
|
}
|
||||||
info.GetReturnValue().Set(
|
info.GetReturnValue().Set(
|
||||||
Nan::New(grpc_channel_get_target(channel->wrapped_channel))
|
Nan::New(grpc_channel_get_target(channel->wrapped_channel))
|
||||||
.ToLocalChecked());
|
.ToLocalChecked());
|
||||||
|
|
@ -281,6 +285,10 @@ NAN_METHOD(Channel::GetConnectivityState) {
|
||||||
"getConnectivityState can only be called on Channel objects");
|
"getConnectivityState can only be called on Channel objects");
|
||||||
}
|
}
|
||||||
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
||||||
|
if (channel->wrapped_channel == NULL) {
|
||||||
|
return Nan::ThrowError(
|
||||||
|
"Cannot call getConnectivityState on a closed Channel");
|
||||||
|
}
|
||||||
int try_to_connect = (int)info[0]->Equals(Nan::True());
|
int try_to_connect = (int)info[0]->Equals(Nan::True());
|
||||||
info.GetReturnValue().Set(grpc_channel_check_connectivity_state(
|
info.GetReturnValue().Set(grpc_channel_check_connectivity_state(
|
||||||
channel->wrapped_channel, try_to_connect));
|
channel->wrapped_channel, try_to_connect));
|
||||||
|
|
@ -303,12 +311,16 @@ NAN_METHOD(Channel::WatchConnectivityState) {
|
||||||
return Nan::ThrowTypeError(
|
return Nan::ThrowTypeError(
|
||||||
"watchConnectivityState's third argument must be a callback");
|
"watchConnectivityState's third argument must be a callback");
|
||||||
}
|
}
|
||||||
|
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
||||||
|
if (channel->wrapped_channel == NULL) {
|
||||||
|
return Nan::ThrowError(
|
||||||
|
"Cannot call watchConnectivityState on a closed Channel");
|
||||||
|
}
|
||||||
grpc_connectivity_state last_state = static_cast<grpc_connectivity_state>(
|
grpc_connectivity_state last_state = static_cast<grpc_connectivity_state>(
|
||||||
Nan::To<uint32_t>(info[0]).FromJust());
|
Nan::To<uint32_t>(info[0]).FromJust());
|
||||||
double deadline = Nan::To<double>(info[1]).FromJust();
|
double deadline = Nan::To<double>(info[1]).FromJust();
|
||||||
Local<Function> callback_func = info[2].As<Function>();
|
Local<Function> callback_func = info[2].As<Function>();
|
||||||
Nan::Callback *callback = new Callback(callback_func);
|
Nan::Callback *callback = new Callback(callback_func);
|
||||||
Channel *channel = ObjectWrap::Unwrap<Channel>(info.This());
|
|
||||||
unique_ptr<OpVec> ops(new OpVec());
|
unique_ptr<OpVec> ops(new OpVec());
|
||||||
grpc_channel_watch_connectivity_state(
|
grpc_channel_watch_connectivity_state(
|
||||||
channel->wrapped_channel, last_state, MillisecondsToTimespec(deadline),
|
channel->wrapped_channel, last_state, MillisecondsToTimespec(deadline),
|
||||||
|
|
|
||||||
|
|
@ -816,7 +816,7 @@ declare module "grpc" {
|
||||||
* Additional peer verification options that can be set when creating
|
* Additional peer verification options that can be set when creating
|
||||||
* SSL credentials.
|
* SSL credentials.
|
||||||
*/
|
*/
|
||||||
export interface VerifyOptions: {
|
export interface VerifyOptions {
|
||||||
/**
|
/**
|
||||||
* If set, this callback will be invoked after the usual hostname verification
|
* If set, this callback will be invoked after the usual hostname verification
|
||||||
* has been performed on the peer certificate.
|
* has been performed on the peer certificate.
|
||||||
|
|
@ -1538,7 +1538,7 @@ declare module "grpc" {
|
||||||
* @param callback Called with no error when a state change, or with an
|
* @param callback Called with no error when a state change, or with an
|
||||||
* error if the deadline passes without a state change.
|
* error if the deadline passes without a state change.
|
||||||
*/
|
*/
|
||||||
watchConnectivityState(currentState: connectivityState, deadline: Date|number, callback: (error?: Error) => void);
|
watchConnectivityState(currentState: connectivityState, deadline: Date|number, callback: (error?: Error) => void): void;
|
||||||
/**
|
/**
|
||||||
* Create a call object. Call is an opaque type that is used by the Client
|
* Create a call object. Call is an opaque type that is used by the Client
|
||||||
* and Server classes. This function is called by the gRPC library when
|
* and Server classes. This function is called by the gRPC library when
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./node_modules/.bin/node-pre-gyp build",
|
"build": "node-pre-gyp build",
|
||||||
"electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
|
"electron-build": "node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
|
||||||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha test",
|
"coverage": "istanbul cover ./node_modules/.bin/_mocha test",
|
||||||
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build --library=static_library",
|
"install": "node-pre-gyp install --fallback-to-build --library=static_library",
|
||||||
"prepack": "git submodule update --init --recursive && npm install"
|
"prepack": "git submodule update --init --recursive && npm install"
|
||||||
},
|
},
|
||||||
"bundledDependencies": [
|
"bundledDependencies": [
|
||||||
|
|
@ -67,7 +67,8 @@
|
||||||
"ext/*.{cc,h}",
|
"ext/*.{cc,h}",
|
||||||
"deps/grpc/include/grpc/**/*.h",
|
"deps/grpc/include/grpc/**/*.h",
|
||||||
"deps/grpc/src/core/**/*.{c,cc,h}",
|
"deps/grpc/src/core/**/*.{c,cc,h}",
|
||||||
"deps/grpc/src/boringssl/*.{c,cc,h}",
|
"deps/grpc/src/boringssl/err_data.c",
|
||||||
|
"deps/grpc/src/cpp/ext/filters/census/grpc_context.cc",
|
||||||
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
|
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
|
||||||
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
|
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
|
||||||
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
|
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
|
||||||
|
|
|
||||||
|
|
@ -720,13 +720,23 @@ Client.prototype.waitForReady = function(deadline, callback) {
|
||||||
callback(new Error('Failed to connect before the deadline'));
|
callback(new Error('Failed to connect before the deadline'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var new_state = self.$channel.getConnectivityState(true);
|
var new_state;
|
||||||
|
try {
|
||||||
|
new_state = self.$channel.getConnectivityState(true);
|
||||||
|
} catch (e) {
|
||||||
|
callback(new Error('The channel has been closed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (new_state === grpc.connectivityState.READY) {
|
if (new_state === grpc.connectivityState.READY) {
|
||||||
callback();
|
callback();
|
||||||
} else if (new_state === grpc.connectivityState.FATAL_FAILURE) {
|
} else if (new_state === grpc.connectivityState.FATAL_FAILURE) {
|
||||||
callback(new Error('Failed to connect to server'));
|
callback(new Error('Failed to connect to server'));
|
||||||
} else {
|
} else {
|
||||||
self.$channel.watchConnectivityState(new_state, deadline, checkState);
|
try {
|
||||||
|
self.$channel.watchConnectivityState(new_state, deadline, checkState);
|
||||||
|
} catch (e) {
|
||||||
|
callback(new Error('The channel has been closed'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* Force a single round of polling to ensure that the channel state is up
|
/* Force a single round of polling to ensure that the channel state is up
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./node_modules/.bin/node-pre-gyp build",
|
"build": "node-pre-gyp build",
|
||||||
"electron-build": "./node_modules/.bin/node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
|
"electron-build": "node-pre-gyp configure build --runtime=electron --disturl=https://atom.io/download/atom-shell",
|
||||||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha test",
|
"coverage": "istanbul cover ./node_modules/.bin/_mocha test",
|
||||||
"install": "./node_modules/.bin/node-pre-gyp install --fallback-to-build --library=static_library",
|
"install": "node-pre-gyp install --fallback-to-build --library=static_library",
|
||||||
"prepack": "git submodule update --init --recursive && npm install"
|
"prepack": "git submodule update --init --recursive && npm install"
|
||||||
},
|
},
|
||||||
"bundledDependencies": [
|
"bundledDependencies": [
|
||||||
|
|
@ -69,7 +69,8 @@
|
||||||
"ext/*.{cc,h}",
|
"ext/*.{cc,h}",
|
||||||
"deps/grpc/include/grpc/**/*.h",
|
"deps/grpc/include/grpc/**/*.h",
|
||||||
"deps/grpc/src/core/**/*.{c,cc,h}",
|
"deps/grpc/src/core/**/*.{c,cc,h}",
|
||||||
"deps/grpc/src/boringssl/*.{c,cc,h}",
|
"deps/grpc/src/boringssl/err_data.c",
|
||||||
|
"deps/grpc/src/cpp/ext/filters/census/grpc_context.cc",
|
||||||
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
|
"deps/grpc/third_party/nanopb/*.{c,cc,h}",
|
||||||
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
|
"deps/grpc/third_party/zlib/**/*.{c,cc,h}",
|
||||||
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
|
"deps/grpc/third_party/boringssl/crypto/**/*.{c,cc,h}",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue