Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Feb 13, 2025
1 parent c0b8f43 commit 28daee3
Show file tree
Hide file tree
Showing 14 changed files with 691 additions and 104 deletions.
156 changes: 130 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"rust/auth",
"rust/conn_pool",
"rust/pgrust",
"rust/http",
"rust/gel-http",
"rust/pyo3_util"
]
resolver = "2"
Expand All @@ -22,7 +22,7 @@ tracing-subscriber = { version = "0.3.18", features = ["registry", "env-filter"]
gel_auth = { path = "rust/auth" }
conn_pool = { path = "rust/conn_pool" }
pgrust = { path = "rust/pgrust" }
http = { path = "rust/http" }
gel-http = { path = "rust/gel-http" }
pyo3_util = { path = "rust/pyo3_util" }

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion edb/server/_rust_native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tokio.workspace = true
pyo3_util.workspace = true
conn_pool = { workspace = true, features = [ "python_extension" ] }
pgrust = { workspace = true, features = [ "python_extension" ] }
http = { workspace = true, features = [ "python_extension" ] }
gel-http = { workspace = true, features = [ "python_extension" ] }

[lib]
crate-type = ["lib", "cdylib"]
Expand Down
2 changes: 1 addition & 1 deletion edb/server/_rust_native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn _rust_native(py: Python, m: &Bound<PyModule>) -> PyResult<()> {

add_child_module(py, m, "_conn_pool", conn_pool::python::_conn_pool)?;
add_child_module(py, m, "_pg_rust", pgrust::python::_pg_rust)?;
add_child_module(py, m, "_http", http::python::_http)?;
add_child_module(py, m, "_http", gel_http::python::_gel_http)?;

Ok(())
}
31 changes: 26 additions & 5 deletions edb/server/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ async def request(
headers: HeaderType = None,
data: bytes | str | dict[str, str] | None = None,
json: Any | None = None,
cache: bool = False,
) -> tuple[int, bytearray, dict[str, str]]:
self._ensure_task()
path = self._process_path(path)
Expand All @@ -191,7 +192,9 @@ async def request(
self._requests[id] = asyncio.Future()
start_time = time.monotonic()
try:
self._ensure_client()._request(id, path, method, data, headers_list)
self._ensure_client()._request(
id, path, method, data, headers_list, cache
)
resp = await self._requests[id]
if self._stat_callback:
status_code, body, headers = resp
Expand All @@ -217,9 +220,15 @@ async def request(
finally:
del self._requests[id]

async def get(self, path: str, *, headers: HeaderType = None) -> Response:
async def get(
self,
path: str,
*,
headers: HeaderType = None,
cache: bool = False,
) -> Response:
result = await self.request(
method="GET", path=path, data=None, headers=headers
method="GET", path=path, data=None, headers=headers, cache=cache
)
return Response.from_tuple(result)

Expand Down Expand Up @@ -387,12 +396,24 @@ def _process_path(self, path):
return path

async def request(
self, *, method, path, headers=None, data=None, json=None
self,
*,
method,
path,
headers=None,
data=None,
json=None,
cache=False,
):
path = self._process_path(path)
headers = self._process_headers(headers)
return await self.http_client.request(
method=method, path=path, headers=headers, data=data, json=json
method=method,
path=path,
headers=headers,
data=data,
json=json,
cache=cache,
)

async def stream_sse(
Expand Down
Loading

0 comments on commit 28daee3

Please sign in to comment.