-
Notifications
You must be signed in to change notification settings - Fork 116
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
Refactore HttpClient and HttpFuture #127
Conversation
Conflicts: bravado/client.py bravado/mapping/operation.py docs/source/quickstart.rst tests/client_test.py
return fido.fetch(url, **request_params) | ||
fido_future = FidoFuture(op, url, request_params) | ||
fido_future.fetch() | ||
return fido_future |
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.
docstring and return type don't match. Also add op
to docstring
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.
ack.
lgtm except for the minor stuff |
""" | ||
|
||
def start_request(self, request_params): | ||
def request(self, request_params, op=None): |
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 operation is required, I would make it a regular argument, not a kwarg.
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.
This is because op
is not required for api-docs fetch. For that instance, client.request(request_params)
has to be called without op
.
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.
Ah, ok, fair enough, kwargs works
This is looks good, I think with a few more small changes we can remove the mutability and inheritance as well |
|
||
# op is not present during api-docs fetch, return raw response | ||
if not self.op: | ||
return response |
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 think having very different responses based on the presence of an operation is kind of unexpected.
I also just noticed that self.op is only being used the unmarshal the response.
It seems like this interface would be much more concise if unmarshal_response(response, op)
were actually called by whatever calls this.
That would allow us to remove self.op as a parameter entirely.
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.
Ya, I think we can accomplish this by restoring handle_response(response, op)
, but without any of the branch logic. Since the adapters normalize the response to a single representation.
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.
Ack.
Conflicts: bravado/mapping/operation.py tests/mapping/operation/unmarshal_response_test.py tests/resource_response_test.py
@analogue I saw that in the integration tests, Also, functional tests fail with |
:type response_adapter: :class: `bravado.mapping.response.ResponseLike` | ||
:param callback: Function to be called on the response | ||
""" | ||
self.request_adapter = request_adapter |
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.
s/request_adapter/future/ , since the interface is concurrent.futures.Future
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.
ack
This looks great! Thanks for making all the changes. Just some minor rename/docstring stuff left |
@analogue I am adding |
@@ -2,7 +2,7 @@ | |||
# -*- coding: utf-8 -*- |
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.
looks like there are some remaining
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.
Removed the line: #!/usr/bin/env python
.
Shouldn't we define the python encoding as utf-8
instead of default ascii as the best practice?
|
lgtm! good job |
Refactor HttpClient and HttpFuture
HttpClient
andHttpFuture
#120 (Most of the implementation taken from comments of [bravado] Replace inbuilt async client with fido #117)HttpClient
andHttpFuture
are place inbravado.mapping
bravado/
SynchronousEventual
andhandle_respone
testsPending: