Merge pull request #2132 from ajmath/ajmath/expose-call-items

Expose path and callEnd event in ServerSurfaceCall
This commit is contained in:
Michael Lumish 2022-09-06 15:22:09 -07:00 committed by GitHub
commit 1a3600e2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -80,6 +80,7 @@ export type ServerSurfaceCall = {
getPeer(): string; getPeer(): string;
sendMetadata(responseMetadata: Metadata): void; sendMetadata(responseMetadata: Metadata): void;
getDeadline(): Deadline; getDeadline(): Deadline;
getPath(): string;
} & EventEmitter; } & EventEmitter;
export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & { export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
@ -127,6 +128,10 @@ export class ServerUnaryCallImpl<RequestType, ResponseType>
getDeadline(): Deadline { getDeadline(): Deadline {
return this.call.getDeadline(); return this.call.getDeadline();
} }
getPath(): string {
return this.call.getPath();
}
} }
export class ServerReadableStreamImpl<RequestType, ResponseType> export class ServerReadableStreamImpl<RequestType, ResponseType>
@ -165,6 +170,10 @@ export class ServerReadableStreamImpl<RequestType, ResponseType>
getDeadline(): Deadline { getDeadline(): Deadline {
return this.call.getDeadline(); return this.call.getDeadline();
} }
getPath(): string {
return this.call.getPath();
}
} }
export class ServerWritableStreamImpl<RequestType, ResponseType> export class ServerWritableStreamImpl<RequestType, ResponseType>
@ -202,6 +211,10 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
return this.call.getDeadline(); return this.call.getDeadline();
} }
getPath(): string {
return this.call.getPath();
}
_write( _write(
chunk: ResponseType, chunk: ResponseType,
encoding: string, encoding: string,
@ -279,6 +292,10 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
return this.call.getDeadline(); return this.call.getDeadline();
} }
getPath(): string {
return this.call.getPath();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
end(metadata?: any) { end(metadata?: any) {
if (metadata) { if (metadata) {
@ -726,6 +743,8 @@ export class Http2ServerCallStream<
call.cancelled = true; call.cancelled = true;
call.emit('cancelled', reason); call.emit('cancelled', reason);
}); });
this.once('callEnd', (status) => call.emit('callEnd', status));
} }
setupReadable( setupReadable(
@ -899,6 +918,10 @@ export class Http2ServerCallStream<
getDeadline(): Deadline { getDeadline(): Deadline {
return this.deadline; return this.deadline;
} }
getPath(): string {
return this.handler.path;
}
} }
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */