mirror of https://github.com/grpc/grpc-node.git
grpc-js: Update some types and type checks for compatibility with grpc-gcp
This commit is contained in:
parent
11e2e048b5
commit
91dc475dd5
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@grpc/grpc-js",
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.3",
|
||||
"description": "gRPC Library for Node - pure JS implementation",
|
||||
"homepage": "https://grpc.io/",
|
||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||
|
|
|
@ -110,9 +110,9 @@ export interface Channel {
|
|||
*/
|
||||
createCall(
|
||||
method: string,
|
||||
deadline: Deadline | null | undefined,
|
||||
deadline: Deadline,
|
||||
host: string | null | undefined,
|
||||
parentCall: Call | null | undefined,
|
||||
parentCall: any,
|
||||
propagateFlags: number | null | undefined
|
||||
): Call;
|
||||
}
|
||||
|
@ -140,6 +140,15 @@ export class ChannelImplementation implements Channel {
|
|||
private readonly credentials: ChannelCredentials,
|
||||
private readonly options: ChannelOptions
|
||||
) {
|
||||
if (typeof target !== 'string') {
|
||||
throw new TypeError('Channel target must be a string');
|
||||
}
|
||||
if (!(credentials instanceof ChannelCredentials)) {
|
||||
throw new TypeError('Channel credentials must be a ChannelCredentials object');
|
||||
}
|
||||
if ((typeof options !== 'object') || !Object.values(options).every(value => typeof value === 'string' || typeof value === 'number')) {
|
||||
throw new TypeError('Channel options must be an object with string or number values');
|
||||
}
|
||||
/* The global boolean parameter to getSubchannelPool has the inverse meaning to what
|
||||
* the grpc.use_local_subchannel_pool channel option means. */
|
||||
this.subchannelPool = getSubchannelPool(
|
||||
|
@ -430,11 +439,17 @@ export class ChannelImplementation implements Channel {
|
|||
|
||||
createCall(
|
||||
method: string,
|
||||
deadline: Deadline | null | undefined,
|
||||
deadline: Deadline,
|
||||
host: string | null | undefined,
|
||||
parentCall: Call | null | undefined,
|
||||
parentCall: any,
|
||||
propagateFlags: number | null | undefined
|
||||
): Call {
|
||||
if (typeof method !== 'string') {
|
||||
throw new TypeError('Channel#createCall: method must be a string');
|
||||
}
|
||||
if (!(typeof deadline === 'number' || deadline instanceof Date)) {
|
||||
throw new TypeError('Channel#createCall: deadline must be a number or Date');
|
||||
}
|
||||
if (this.connectivityState === ConnectivityState.SHUTDOWN) {
|
||||
throw new Error('Channel has been shut down');
|
||||
}
|
||||
|
@ -451,8 +466,7 @@ export class ChannelImplementation implements Channel {
|
|||
deadline
|
||||
);
|
||||
const finalOptions: CallStreamOptions = {
|
||||
deadline:
|
||||
deadline === null || deadline === undefined ? Infinity : deadline,
|
||||
deadline: deadline,
|
||||
flags: propagateFlags || 0,
|
||||
host: host || this.defaultAuthority,
|
||||
parentCall: parentCall || null,
|
||||
|
|
|
@ -48,6 +48,7 @@ import {
|
|||
InterceptorArguments,
|
||||
InterceptingCallInterface,
|
||||
} from './client-interceptors';
|
||||
import { ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream } from './server-call';
|
||||
|
||||
const CHANNEL_SYMBOL = Symbol();
|
||||
const INTERCEPTOR_SYMBOL = Symbol();
|
||||
|
@ -61,8 +62,7 @@ export interface UnaryCallback<ResponseType> {
|
|||
export interface CallOptions {
|
||||
deadline?: Deadline;
|
||||
host?: string;
|
||||
/* There should be a parent option here that will accept a server call,
|
||||
* but the server is not yet implemented so it makes no sense to have it */
|
||||
parent?: ServerUnaryCall<any, any> | ServerReadableStream<any, any> | ServerWritableStream<any, any> | ServerDuplexStream<any, any>
|
||||
propagate_flags?: number;
|
||||
credentials?: CallCredentials;
|
||||
interceptors?: Interceptor[];
|
||||
|
|
|
@ -28,7 +28,7 @@ import { CallCredentials } from './call-credentials';
|
|||
import { Deadline, StatusObject } from './call-stream';
|
||||
import { Channel, ConnectivityState, ChannelImplementation } from './channel';
|
||||
import { ChannelCredentials } from './channel-credentials';
|
||||
import { CallOptions, Client } from './client';
|
||||
import { CallOptions, Client, CallInvocationTransformer, CallProperties } from './client';
|
||||
import { LogVerbosity, Status } from './constants';
|
||||
import * as logging from './logging';
|
||||
import {
|
||||
|
@ -199,7 +199,10 @@ export {
|
|||
loadPackageDefinition,
|
||||
makeClientConstructor,
|
||||
makeClientConstructor as makeGenericClientConstructor,
|
||||
CallProperties,
|
||||
CallInvocationTransformer,
|
||||
ChannelImplementation as Channel,
|
||||
Channel as ChannelInterface
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue