grpc-js: Add end(md?: Metadata) method to streaming server calls

This commit is contained in:
Michael Lumish 2020-08-04 11:37:08 -07:00
parent f08d3aefd0
commit d9b3f9f364
1 changed files with 14 additions and 2 deletions

View File

@ -91,10 +91,13 @@ export type ServerWritableStream<
RequestType,
ResponseType
> = ServerSurfaceCall &
ObjectWritable<ResponseType> & { request: RequestType | null };
ObjectWritable<ResponseType> & {
request: RequestType | null;
end: (metadata?: Metadata) => void;
};
export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
ObjectReadable<RequestType> &
ObjectWritable<ResponseType>;
ObjectWritable<ResponseType> & { end: (metadata?: Metadata) => void };
export class ServerUnaryCallImpl<RequestType, ResponseType> extends EventEmitter
implements ServerUnaryCall<RequestType, ResponseType> {
@ -255,6 +258,15 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType> extends Duplex
sendMetadata(responseMetadata: Metadata): void {
this.call.sendMetadata(responseMetadata);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
end(metadata?: any) {
if (metadata) {
this.trailingMetadata = metadata;
}
super.end();
}
}
ServerDuplexStreamImpl.prototype._read =