Skip to content

Commit

Permalink
feat: configurable timeout and cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurD1 committed Jun 6, 2024
1 parent 9f84811 commit 88b9b3a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions harp_apps/http_client/__app__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ class AsyncHttpClient(AsyncClient):

def __init__(self, settings: HttpClientSettings):
transport = AsyncHTTPTransport()
if settings.cache and not settings.cache.disabled:
if not (settings.cache and settings.cache.disabled):
controller = Controller(
allow_heuristics=True,
cacheable_methods=settings.cache.cacheable_methods,
cacheable_status_codes=settings.cache.cacheable_status_codes
or list(HEURISTICALLY_CACHEABLE_STATUS_CODES),
cacheable_methods=settings.cache.cacheable_methods if settings.cache else None,
cacheable_status_codes=(
settings.cache.cacheable_status_codes
if settings.cache
else None or list(HEURISTICALLY_CACHEABLE_STATUS_CODES)
),
allow_stale=True,
)
transport = AsyncCacheTransport(transport=transport, controller=controller)
Expand Down

0 comments on commit 88b9b3a

Please sign in to comment.