Skip to content

Commit

Permalink
Add config for optional http2 usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberbudy committed Jun 24, 2024
1 parent 9301002 commit 6de02a7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion async_firebase/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
*,
request_timeout: RequestTimeout = DEFAULT_REQUEST_TIMEOUT,
request_limits: RequestLimits = DEFAULT_REQUEST_LIMITS,
use_http2: bool = False
) -> None:
"""
:param credentials: instance of ``google.oauth2.service_account.Credentials``.
Expand All @@ -66,12 +67,14 @@ def __init__(
:param scopes: user-defined scopes to request during the authorization grant.
:param request_timeout: advanced feature that allows to change request timeout.
:param request_limits: advanced feature that allows to control the connection pool size.
:param use_http2: advanced feature that allows to control usage of http protocol.
"""
self._credentials: service_account.Credentials = credentials
self.scopes: t.List[str] = scopes or self.SCOPES

self._request_timeout = request_timeout
self._request_limits = request_limits
self._use_http2 = use_http2
self._http_client: t.Optional[httpx.AsyncClient] = None

@property
Expand All @@ -80,7 +83,7 @@ def _client(self) -> httpx.AsyncClient:
self._http_client = httpx.AsyncClient(
timeout=httpx.Timeout(**self._request_timeout.__dict__),
limits=httpx.Limits(**self._request_limits.__dict__),
http2=True
http2=self._use_http2
)
return self._http_client

Expand Down

0 comments on commit 6de02a7

Please sign in to comment.