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

[Service Bus] Generic types for Responses for a cleaner API surface #10491

Merged
14 commits merged into from Oct 22, 2020

Conversation

HarshaNalluru
Copy link
Member

@HarshaNalluru HarshaNalluru commented Aug 7, 2020

image
image

Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

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

No opinion on this yet but I think this hinges on what you decide as far as how we want to handle Response.

  1. We can inline Response's fields which will remove one interface from the top level surface.
  2. We can use this generics method. Curious what the docs look like for it.
  3. We can just do the extends methodology.

@ramya-rao-a
Copy link
Contributor

cc @bterlson, @xirzec

@HarshaNalluru
Copy link
Member Author

HarshaNalluru commented Aug 25, 2020

We can use this generics method. Curious what the docs look like for it.

Example Method

image

Response Type in the Docs

image

@richardpark-msft

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

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

I love using a generic for this, as I think it looks a lot better.

My only suggestion is maybe the response interface is too broad for what we want to expose, though I recognize that you haven't changed it from the previous release. Maybe we can discuss how to standardize this across libraries tomorrow?

@@ -263,9 +250,9 @@ export interface ReceiveMessagesOptions extends OperationOptionsBase {
export type ReceiveMode = "peekLock" | "receiveAndDelete";

// @public
export interface Response {
export type Response<T> = T & {
_response: HttpOperationResponse;
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be HttpResponse instead? HttpOperationResponse has a lot of internal details that don't add much value to the consumer, whereas HttpResponse is enough to get headers, status, and the original request.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm.. we never cared enough to update. We can make it HTTPResponse.

For reference,

// Service Bus
_response: HttpOperationResponse;

// From core-http
export interface HttpOperationResponse extends HttpResponse {
  parsedHeaders?: { [key: string]: any };
  bodyAsText?: string | null;
  parsedBody?: any;
  blobBody?: Promise<Blob>;
  readableStreamBody?: NodeJS.ReadableStream;
}

// Example for `_response` in storage 
_response: HttpResponse & {
  parsedHeaders: ServiceGetUserDelegationKeyHeaders;
  bodyAsText: string;
  parsedBody: UserDelegationKeyModel;
};

Maybe we should consider standardizing the _responses?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this is beyond the scope of this PR, logging a new issue to update to _response: HTTPResponse - #10841
I'll put up a PR for this if nobody has objections.

Copy link
Member Author

Choose a reason for hiding this comment

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

Response from the proposal has been renamed to WithResponse.

@HarshaNalluru
Copy link
Member Author

Feedback from @bterlson (from offline):

  • WithResponse is fine, _response: HTTPResponse (as @xirzec suggested) is also fine
  • Suggested a generic constraint on WithResponse<T>
    • Example: WithResponse<number> should be an error
    • Can do T extends object

@deyaaeldeen
Copy link
Member

One thing to consider here is the inconsistency in how to provide _response to our users as tracked by this issue: #10887. This is already an existing issue so I think there is no reason to block this PR as is.

@HarshaNalluru
Copy link
Member Author

Thanks, @deyaaeldeen.
I will push updating _response: HTTPResponse to a follow up PR.

@ghost
Copy link

ghost commented Oct 22, 2020

Hello @HarshaNalluru!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@HarshaNalluru
Copy link
Member Author

/check-enforcer override

@ghost ghost merged commit 91b20e3 into Azure:master Oct 22, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants