Skip to content

Commit 7e7cc36

Browse files
author
joel@joellee.org
committed
fix: add shadow method
1 parent 20cc55d commit 7e7cc36

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

supabase/client.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from httpx import Timeout
55
from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder
66
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
7+
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
78
from supafunc import FunctionsClient
89

910
from .lib.auth_client import SupabaseAuthClient
@@ -89,7 +90,10 @@ def __init__(
8990
supabase_key=self.supabase_key,
9091
headers=options.headers,
9192
schema=options.schema,
92-
timeout=options.timeout,
93+
timeout=options.postgrest_client_timeout,
94+
)
95+
self.storage = self._init_storage_client(
96+
self.storage_url, self._get_auth_headers(), options.storage_client_timeout
9397
)
9498

9599
def functions(self) -> FunctionsClient:
@@ -168,6 +172,13 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder:
168172
# return SupabaseRealtimeClient(
169173
# realtime_url, {"params": {"apikey": supabase_key}}
170174
# )
175+
@staticmethod
176+
def _init_storage_client(
177+
storage_url: str,
178+
headers: Dict[str, str],
179+
storage_client_timeout: int = DEFAULT_STORAGE_CLIENT_TIMEOUT,
180+
) -> SupabaseStorageClient:
181+
return SupabaseStorageClient(storage_url, headers, storage_client_timeout)
171182

172183
@staticmethod
173184
def _init_supabase_auth_client(

supabase/lib/client_options.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from gotrue import SyncMemoryStorage, SyncSupportedStorage
55
from httpx import Timeout
66
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
7+
from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT
78

89
from supabase import __version__
910

@@ -36,9 +37,14 @@ class ClientOptions:
3637
fetch: Optional[Callable] = None
3738
"""A custom `fetch` implementation."""
3839

39-
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
40+
postgrest_client_timeout: Union[
41+
int, float, Timeout
42+
] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
4043
"""Timeout passed to the SyncPostgrestClient instance."""
4144

45+
storage_client_timeout: Uniont[int, float, Timeout] = DEFAULT_STORAGE_CLIENT_TIMEOUT
46+
"""Timeout passed to the SyncStorageClient instance"""
47+
4248
def replace(
4349
self,
4450
schema: Optional[str] = None,
@@ -48,7 +54,12 @@ def replace(
4854
storage: Optional[SyncSupportedStorage] = None,
4955
realtime: Optional[Dict[str, Any]] = None,
5056
fetch: Optional[Callable] = None,
51-
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
57+
postgrest_client_timeout: Union[
58+
int, float, Timeout
59+
] = DEFAULT_POSTGREST_CLIENT_TIMEOUT,
60+
storage_client_timeout: Union[
61+
int, float, Timeout
62+
] = DEFAULT_STORAGE_CLIENT_TIMEOUT,
5263
) -> "ClientOptions":
5364
"""Create a new SupabaseClientOptions with changes"""
5465
client_options = ClientOptions()
@@ -61,5 +72,10 @@ def replace(
6172
client_options.storage = storage or self.storage
6273
client_options.realtime = realtime or self.realtime
6374
client_options.fetch = fetch or self.fetch
64-
client_options.timeout = timeout or self.timeout
75+
client_options.postgrest_client_timeout = (
76+
postgrest_client_timeout or self.postgrest_client_timeout
77+
)
78+
client_options.storage_client_timeout = (
79+
storage_client_timeout or self.storage_client_timeout
80+
)
6581
return client_options

0 commit comments

Comments
 (0)