mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-29 02:31:00 +00:00
Add TAKAHE_DEFAULT_TIMEOUT with default of 5.0 (#99)
This commit is contained in:
parent
0efa445605
commit
61c1058d67
4 changed files with 25 additions and 1 deletions
|
@ -7,9 +7,11 @@ import httpx
|
||||||
from cryptography.exceptions import InvalidSignature
|
from cryptography.exceptions import InvalidSignature
|
||||||
from cryptography.hazmat.primitives import hashes, serialization
|
from cryptography.hazmat.primitives import hashes, serialization
|
||||||
from cryptography.hazmat.primitives.asymmetric import padding, rsa
|
from cryptography.hazmat.primitives.asymmetric import padding, rsa
|
||||||
|
from django.conf import settings
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.http import http_date, parse_http_date
|
from django.utils.http import http_date, parse_http_date
|
||||||
|
from httpx._types import TimeoutTypes
|
||||||
from pyld import jsonld
|
from pyld import jsonld
|
||||||
|
|
||||||
from core.ld import format_ld_date
|
from core.ld import format_ld_date
|
||||||
|
@ -173,6 +175,7 @@ class HttpSignature:
|
||||||
key_id: str,
|
key_id: str,
|
||||||
content_type: str = "application/json",
|
content_type: str = "application/json",
|
||||||
method: Literal["get", "post"] = "post",
|
method: Literal["get", "post"] = "post",
|
||||||
|
timeout: TimeoutTypes = settings.SETUP.REMOTE_TIMEOUT,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Performs an async request to the given path, with a document, signed
|
Performs an async request to the given path, with a document, signed
|
||||||
|
@ -219,7 +222,7 @@ class HttpSignature:
|
||||||
)
|
)
|
||||||
# Send the request with all those headers except the pseudo one
|
# Send the request with all those headers except the pseudo one
|
||||||
del headers["(request-target)"]
|
del headers["(request-target)"]
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
method,
|
method,
|
||||||
uri,
|
uri,
|
||||||
|
|
|
@ -19,4 +19,5 @@ in alpha. For more information about Takahē, see
|
||||||
contributing
|
contributing
|
||||||
domains
|
domains
|
||||||
stator
|
stator
|
||||||
|
tuning
|
||||||
releases/index
|
releases/index
|
||||||
|
|
16
docs/tuning.rst
Normal file
16
docs/tuning.rst
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Tuning
|
||||||
|
======
|
||||||
|
|
||||||
|
This page contains a collection of tips and settings that can be used to
|
||||||
|
tune your server based upon its users and the other servers it federates
|
||||||
|
with.
|
||||||
|
|
||||||
|
Federating
|
||||||
|
----------
|
||||||
|
|
||||||
|
Environment Variable:
|
||||||
|
|
||||||
|
* ``TAKAHE_REMOTE_TIMEOUT`` is the number of seconds Takahē will allow when
|
||||||
|
making remote requests to other Fediverse instances. This may also be a
|
||||||
|
tuple of four floats to set the timeouts for connect, read, write, and
|
||||||
|
pool. Example ``TAKAHE_REMOTE_TIMEOUT='[0.5, 1.0, 1.0, 0.5]'``
|
|
@ -90,6 +90,10 @@ class Settings(BaseSettings):
|
||||||
MEDIA_ROOT: str = str(BASE_DIR / "media")
|
MEDIA_ROOT: str = str(BASE_DIR / "media")
|
||||||
MEDIA_BACKEND: Optional[MediaBackendUrl] = None
|
MEDIA_BACKEND: Optional[MediaBackendUrl] = None
|
||||||
|
|
||||||
|
#: Request timeouts to use when talking to other servers Either
|
||||||
|
#: float or tuple of floats for (connect, read, write, pool)
|
||||||
|
REMOTE_TIMEOUT: float | tuple[float, float, float, float] = 5.0
|
||||||
|
|
||||||
#: If search features like full text search should be enabled.
|
#: If search features like full text search should be enabled.
|
||||||
#: (placeholder setting, no effect)
|
#: (placeholder setting, no effect)
|
||||||
SEARCH: bool = True
|
SEARCH: bool = True
|
||||||
|
|
Loading…
Reference in a new issue