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

V2: Use Stream{Request|Response} types in interceptors for all streaming rpcs #1230

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/connect/src/interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ export interface StreamResponse<
readonly message: AsyncIterable<MessageShape<O>>;
}

interface RequestCommon<I extends DescMessage, O extends DescMessage> {
/**
* @private
*/
export interface RequestCommon<I extends DescMessage, O extends DescMessage> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up.

Can you mark the two new exports as @private? They are not exported in the package, but this makes it unmistakably clear that they shouldn't be.

/**
* Metadata related to the service that is being called.
*/
Expand Down Expand Up @@ -178,7 +181,10 @@ interface RequestCommon<I extends DescMessage, O extends DescMessage> {
readonly contextValues: ContextValues;
}

interface ResponseCommon<I extends DescMessage, O extends DescMessage> {
/**
* @private
*/
export interface ResponseCommon<I extends DescMessage, O extends DescMessage> {
/**
* Metadata related to the service that is being called.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/connect/src/protocol/invoke-implementation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe("transformInvokeImplementation()", () => {
expect(context.values.get(kFoo)).toEqual("bar");
req.header.set("Key", "bar");
const res = await next(req);
expect(res.stream).toEqual(false);
expect(res.stream).toEqual(true);
expect(res.service).toEqual(TestService);
expect(res.header.get("Key")).toEqual("bar");
expect(res.method).toEqual(TestService.method.clientStreaming);
Expand Down Expand Up @@ -190,7 +190,7 @@ describe("transformInvokeImplementation()", () => {
context,
[
(next) => async (req) => {
expect(req.stream).toEqual(false);
expect(req.stream).toEqual(true);
expect(req.init.method).toEqual("POST");
expect(req.service).toEqual(TestService);
expect(req.header.get("Key")).toEqual("Value");
Expand Down
Loading