Skip to content

Commit 1a3600e

Browse files
authored
Merge pull request #2132 from ajmath/ajmath/expose-call-items
Expose path and callEnd event in ServerSurfaceCall
2 parents 618475a + d846cf5 commit 1a3600e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/grpc-js/src/server-call.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export type ServerSurfaceCall = {
8080
getPeer(): string;
8181
sendMetadata(responseMetadata: Metadata): void;
8282
getDeadline(): Deadline;
83+
getPath(): string;
8384
} & EventEmitter;
8485

8586
export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
@@ -127,6 +128,10 @@ export class ServerUnaryCallImpl<RequestType, ResponseType>
127128
getDeadline(): Deadline {
128129
return this.call.getDeadline();
129130
}
131+
132+
getPath(): string {
133+
return this.call.getPath();
134+
}
130135
}
131136

132137
export class ServerReadableStreamImpl<RequestType, ResponseType>
@@ -165,6 +170,10 @@ export class ServerReadableStreamImpl<RequestType, ResponseType>
165170
getDeadline(): Deadline {
166171
return this.call.getDeadline();
167172
}
173+
174+
getPath(): string {
175+
return this.call.getPath();
176+
}
168177
}
169178

170179
export class ServerWritableStreamImpl<RequestType, ResponseType>
@@ -202,6 +211,10 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
202211
return this.call.getDeadline();
203212
}
204213

214+
getPath(): string {
215+
return this.call.getPath();
216+
}
217+
205218
_write(
206219
chunk: ResponseType,
207220
encoding: string,
@@ -279,6 +292,10 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
279292
return this.call.getDeadline();
280293
}
281294

295+
getPath(): string {
296+
return this.call.getPath();
297+
}
298+
282299
// eslint-disable-next-line @typescript-eslint/no-explicit-any
283300
end(metadata?: any) {
284301
if (metadata) {
@@ -726,6 +743,8 @@ export class Http2ServerCallStream<
726743
call.cancelled = true;
727744
call.emit('cancelled', reason);
728745
});
746+
747+
this.once('callEnd', (status) => call.emit('callEnd', status));
729748
}
730749

731750
setupReadable(
@@ -899,6 +918,10 @@ export class Http2ServerCallStream<
899918
getDeadline(): Deadline {
900919
return this.deadline;
901920
}
921+
922+
getPath(): string {
923+
return this.handler.path;
924+
}
902925
}
903926

904927
/* eslint-disable @typescript-eslint/no-explicit-any */

0 commit comments

Comments
 (0)