Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose path and callEnd event in ServerSurfaceCall #2132

Merged
merged 2 commits into from Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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