Skip to content

Commit

Permalink
Merge pull request #2132 from ajmath/ajmath/expose-call-items
Browse files Browse the repository at this point in the history
Expose path and callEnd event in ServerSurfaceCall
  • Loading branch information
murgatroid99 committed Sep 6, 2022
2 parents 618475a + d846cf5 commit 1a3600e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/grpc-js/src/server-call.ts
Expand Up @@ -80,6 +80,7 @@ export type ServerSurfaceCall = {
getPeer(): string;
sendMetadata(responseMetadata: Metadata): void;
getDeadline(): Deadline;
getPath(): string;
} & EventEmitter;

export type ServerUnaryCall<RequestType, ResponseType> = ServerSurfaceCall & {
Expand Down Expand Up @@ -127,6 +128,10 @@ export class ServerUnaryCallImpl<RequestType, ResponseType>
getDeadline(): Deadline {
return this.call.getDeadline();
}

getPath(): string {
return this.call.getPath();
}
}

export class ServerReadableStreamImpl<RequestType, ResponseType>
Expand Down Expand Up @@ -165,6 +170,10 @@ export class ServerReadableStreamImpl<RequestType, ResponseType>
getDeadline(): Deadline {
return this.call.getDeadline();
}

getPath(): string {
return this.call.getPath();
}
}

export class ServerWritableStreamImpl<RequestType, ResponseType>
Expand Down Expand Up @@ -202,6 +211,10 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
return this.call.getDeadline();
}

getPath(): string {
return this.call.getPath();
}

_write(
chunk: ResponseType,
encoding: string,
Expand Down Expand Up @@ -279,6 +292,10 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
return this.call.getDeadline();
}

getPath(): string {
return this.call.getPath();
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
end(metadata?: any) {
if (metadata) {
Expand Down Expand Up @@ -726,6 +743,8 @@ export class Http2ServerCallStream<
call.cancelled = true;
call.emit('cancelled', reason);
});

this.once('callEnd', (status) => call.emit('callEnd', status));
}

setupReadable(
Expand Down Expand Up @@ -899,6 +918,10 @@ export class Http2ServerCallStream<
getDeadline(): Deadline {
return this.deadline;
}

getPath(): string {
return this.handler.path;
}
}

/* eslint-disable @typescript-eslint/no-explicit-any */
Expand Down

0 comments on commit 1a3600e

Please sign in to comment.