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 Response
s for a cleaner API surface
#10491
[Service Bus] Generic types for Response
s for a cleaner API surface
#10491
Conversation
HarshaNalluru
commented
Aug 7, 2020
•
edited
edited
There was a problem hiding this 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.
- We can inline Response's fields which will remove one interface from the top level surface.
- We can use this generics method. Curious what the docs look like for it.
- We can just do the
extends
methodology.
…to harshan/sb/issue/merge-return-types
Example MethodResponse Type in the Docs |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 _response
s?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
…to harshan/sb/issue/merge-return-types
…to harshan/sb/issue/merge-return-types
One thing to consider here is the inconsistency in how to provide |
Thanks, @deyaaeldeen. |
…to harshan/sb/issue/merge-return-types
…com/HarshaNalluru/azure-sdk-for-js into harshan/sb/issue/merge-return-types
Hello @HarshaNalluru! Because this pull request has the 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 (
|
/check-enforcer override |