Add dependencies for xDS, plus some fixes

This commit is contained in:
Michael Lumish 2020-08-10 15:48:42 -07:00
parent cb63d6afcd
commit 409ad95020
5 changed files with 27 additions and 24 deletions

View File

@ -15,7 +15,6 @@
"types": "build/src/index.d.ts",
"license": "Apache-2.0",
"devDependencies": {
"@grpc/proto-loader": "^0.6.0-pre6",
"@types/gulp": "^4.0.6",
"@types/gulp-mocha": "0.0.32",
"@types/lodash": "^4.14.108",
@ -24,9 +23,9 @@
"@types/node": "^12.7.5",
"@types/pify": "^3.0.2",
"@types/semver": "^6.0.1",
"@types/yargs": "^15.0.5",
"clang-format": "^1.0.55",
"execa": "^2.0.3",
"google-auth-library": "^6.0.0",
"gts": "^2.0.0",
"gulp": "^4.0.2",
"gulp-mocha": "^6.0.0",
@ -36,7 +35,8 @@
"pify": "^4.0.1",
"rimraf": "^3.0.2",
"ts-node": "^8.3.0",
"typescript": "^3.7.2"
"typescript": "^3.7.2",
"yargs": "^15.4.1"
},
"contributors": [
{
@ -49,6 +49,7 @@
"compile": "tsc -p .",
"format": "clang-format -i -style=\"{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}\" src/*.ts test/*.ts",
"generate-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --json --includeComments --includeDirs deps/envoy-api/ deps/udpa/ deps/googleapis/ deps/protoc-gen-validate/ -O src/generated/ --grpcLib ../index envoy/service/discovery/v2/ads.proto envoy/service/load_stats/v2/lrs.proto envoy/api/v2/listener.proto envoy/api/v2/route.proto envoy/api/v2/cluster.proto envoy/api/v2/endpoint.proto envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto",
"generate-interop-types": "proto-loader-gen-types --keep-case --longs String --enums String --defaults --oneofs --json --includeComments --includeDirs proto/ -O interop/generated --grpcLib ../../src grpc/testing/test.proto",
"lint": "npm run check",
"prepare": "npm run compile",
"test": "gulp test",
@ -58,6 +59,8 @@
"posttest": "npm run check"
},
"dependencies": {
"@grpc/proto-loader": "^0.6.0-pre14",
"google-auth-library": "^5.10.1",
"semver": "^6.2.0"
},
"files": [

View File

@ -229,7 +229,7 @@ export class WeightedTargetLoadBalancer implements LoadBalancer {
picker = new WeightedTargetPicker(pickerList);
break;
case ConnectivityState.CONNECTING:
case ConnectivityState.READY:
case ConnectivityState.IDLE:
picker = new QueuePicker(this);
break;
default:

View File

@ -81,7 +81,7 @@ export type ServerSurfaceCall = {
} & EventEmitter;
export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
request: RequestType | null;
request: RequestType;
};
export type ServerReadableStream<
RequestType,
@ -91,7 +91,7 @@ export type ServerWritableStream<
RequestType,
ResponseType
> = ServerSurfaceCall &
ObjectWritable<ResponseType> & { request: RequestType | null };
ObjectWritable<ResponseType> & { request: RequestType };
export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
ObjectReadable<RequestType> &
ObjectWritable<ResponseType>;
@ -99,15 +99,14 @@ export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
export class ServerUnaryCallImpl<RequestType, ResponseType> extends EventEmitter
implements ServerUnaryCall<RequestType, ResponseType> {
cancelled: boolean;
request: RequestType | null;
constructor(
private call: Http2ServerCallStream<RequestType, ResponseType>,
public metadata: Metadata
public metadata: Metadata,
public request: RequestType
) {
super();
this.cancelled = false;
this.request = null;
this.call.setupSurfaceCall(this);
}
@ -157,17 +156,16 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
extends Writable
implements ServerWritableStream<RequestType, ResponseType> {
cancelled: boolean;
request: RequestType | null;
private trailingMetadata: Metadata;
constructor(
private call: Http2ServerCallStream<RequestType, ResponseType>,
public metadata: Metadata,
public serialize: Serialize<ResponseType>
public serialize: Serialize<ResponseType>,
public request: RequestType
) {
super({ objectMode: true });
this.cancelled = false;
this.request = null;
this.trailingMetadata = new Metadata();
this.call.setupSurfaceCall(this);
@ -268,7 +266,7 @@ ServerDuplexStreamImpl.prototype.end = ServerWritableStreamImpl.prototype.end;
// Unary response callback signature.
export type sendUnaryData<ResponseType> = (
error: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
value?: ResponseType | null,
trailer?: Metadata,
flags?: number
) => void;
@ -506,7 +504,7 @@ export class Http2ServerCallStream<
async sendUnaryMessage(
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
value?: ResponseType | null,
metadata?: Metadata,
flags?: number
) {

View File

@ -622,22 +622,23 @@ async function handleUnary<RequestType, ResponseType>(
handler: UnaryHandler<RequestType, ResponseType>,
metadata: Metadata
): Promise<void> {
const emitter = new ServerUnaryCallImpl<RequestType, ResponseType>(
call,
metadata
);
const request = await call.receiveUnaryMessage();
if (request === undefined || call.cancelled) {
return;
}
const emitter = new ServerUnaryCallImpl<RequestType, ResponseType>(
call,
metadata,
request
);
emitter.request = request;
handler.func(
emitter,
(
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
value?: ResponseType | null,
trailer?: Metadata,
flags?: number
) => {
@ -659,7 +660,7 @@ function handleClientStreaming<RequestType, ResponseType>(
function respond(
err: ServerErrorResponse | ServerStatusResponse | null,
value: ResponseType | null,
value?: ResponseType | null,
trailer?: Metadata,
flags?: number
) {
@ -689,10 +690,10 @@ async function handleServerStreaming<RequestType, ResponseType>(
const stream = new ServerWritableStreamImpl<RequestType, ResponseType>(
call,
metadata,
handler.serialize
handler.serialize,
request
);
stream.request = request;
handler.func(stream);
}

View File

@ -10,6 +10,7 @@
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
"test/**/*.ts",
"interop/**/*.ts"
]
}