Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fixup docstrings for matrixfederationclient #4368

Merged
merged 2 commits into from
Jan 9, 2019
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
1 change: 1 addition & 0 deletions changelog.d/4368.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add better logging for unexpected errors while sending transactions
141 changes: 73 additions & 68 deletions synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,18 @@ def _send_request(
backoff_on_404 (bool): Back off if we get a 404

Returns:
Deferred: resolves with the http response object on success.

Fails with ``HttpResponseException``: if we get an HTTP response
code >= 300 (except 429).

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist

Fails with ``RequestSendFailed`` if there were problems connecting to
the remote, due to e.g. DNS failures, connection timeouts etc.
Deferred[twisted.web.client.Response]: resolves with the HTTP
response object on success.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""
if timeout:
_sec_timeout = timeout / 1000
Expand Down Expand Up @@ -516,17 +515,18 @@ def put_json(self, destination, path, args={}, data={},
requests)

Returns:
Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body.

Fails with ``HttpResponseException`` if we get an HTTP response
code >= 300.

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist
Deferred[dict|list]: Succeeds when we get a 2xx HTTP response. The
result will be the decoded JSON body.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""

request = MatrixFederationRequest(
Expand Down Expand Up @@ -570,17 +570,18 @@ def post_json(self, destination, path, data={}, long_retries=False,
try the request anyway.
args (dict): query params
Returns:
Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body.

Fails with ``HttpResponseException`` if we get an HTTP response
code >= 300.

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist
Deferred[dict|list]: Succeeds when we get a 2xx HTTP response. The
result will be the decoded JSON body.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""

request = MatrixFederationRequest(
Expand Down Expand Up @@ -625,17 +626,18 @@ def get_json(self, destination, path, args=None, retry_on_dns_fail=True,
ignore_backoff (bool): true to ignore the historical backoff data
and try the request anyway.
Returns:
Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body.

Fails with ``HttpResponseException`` if we get an HTTP response
code >= 300.

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist
Deferred[dict|list]: Succeeds when we get a 2xx HTTP response. The
result will be the decoded JSON body.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""
logger.debug("get_json args: %s", args)

Expand Down Expand Up @@ -676,17 +678,18 @@ def delete_json(self, destination, path, long_retries=False,
ignore_backoff (bool): true to ignore the historical backoff data and
try the request anyway.
Returns:
Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body.

Fails with ``HttpResponseException`` if we get an HTTP response
code >= 300.

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist
Deferred[dict|list]: Succeeds when we get a 2xx HTTP response. The
result will be the decoded JSON body.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""
request = MatrixFederationRequest(
method="DELETE",
Expand Down Expand Up @@ -719,18 +722,20 @@ def get_file(self, destination, path, output_stream, args={},
args (dict): Optional dictionary used to create the query string.
ignore_backoff (bool): true to ignore the historical backoff data
and try the request anyway.
Returns:
Deferred: resolves with an (int,dict) tuple of the file length and
a dict of the response headers.

Fails with ``HttpResponseException`` if we get an HTTP response code
>= 300

Fails with ``NotRetryingDestination`` if we are not yet ready
to retry this server.

Fails with ``FederationDeniedError`` if this destination
is not on our federation whitelist
Returns:
Deferred[tuple[int, dict]]: Resolves with an (int,dict) tuple of
the file length and a dict of the response headers.

Raises:
HttpResponseException: If we get an HTTP response code >= 300
(except 429).
NotRetryingDestination: If we are not yet ready to retry this
server.
FederationDeniedError: If this destination is not on our
federation whitelist
RequestSendFailed: If there were problems connecting to the
remote, due to e.g. DNS failures, connection timeouts etc.
"""
request = MatrixFederationRequest(
method="GET",
Expand Down