-
Notifications
You must be signed in to change notification settings - Fork 0
feat(nginx)(sphere-sdk-#370): expose /api/v0/dag/import + /api/v0/dag/export #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vrogojin
wants to merge
2
commits into
main
Choose a base branch
from
feat/issue-370-dag-import-export
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,6 +239,64 @@ http { | |
| proxy_pass_header Access-Control-Expose-Headers; | ||
| } | ||
|
|
||
| # DAG import endpoint for CAR-batched UXF Profile pushes | ||
| # (sphere-sdk #370 Part 1). Replaces the per-block /dag/put loop | ||
| # with a SINGLE multipart POST of the full CAR — eliminates the | ||
| # burst of N parallel /dag/put requests during §D.1 pre-clear | ||
| # snapshots. Capability-probed once per process by the SDK at | ||
| # startup; absence here (404 or 405) makes the SDK transparently | ||
| # fall back to the per-block /dag/put path above. | ||
| # | ||
| # client_max_body_size: 100M — CAR-batched bundles carry the | ||
| # full pin payload in a single body (vs ~50KB-1MB per individual | ||
| # block on /dag/put). Sized generously above the typical Profile | ||
| # snapshot (~few MB) to avoid 413 truncation on large wallets. | ||
| # | ||
| # Timeouts: 300s — Kubo's internal pin of every block in a | ||
| # large CAR takes several seconds end-to-end; allow headroom | ||
| # over the typical ~1-2s import time so a slow inner CAR walk | ||
| # doesn't surface as a spurious gateway-side timeout that | ||
| # triggers the SDK's legacy fallback unnecessarily. | ||
| location /api/v0/dag/import { | ||
| client_max_body_size 100M; | ||
| proxy_pass http://127.0.0.1:5001; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_read_timeout 300s; | ||
| proxy_send_timeout 300s; | ||
| proxy_pass_header Access-Control-Allow-Origin; | ||
| proxy_pass_header Access-Control-Allow-Methods; | ||
| proxy_pass_header Access-Control-Allow-Headers; | ||
| proxy_pass_header Access-Control-Expose-Headers; | ||
| } | ||
|
|
||
| # DAG export endpoint for CAR-batched UXF Profile fetches | ||
| # (sphere-sdk #370 Part 1). Replaces the per-block BFS walk | ||
| # (one /api/v0/block/get per block) with a single CAR stream | ||
| # rooted at the requested CID. Capability-probed by the SDK; | ||
| # absence here transparently falls the SDK back to the BFS | ||
| # path above. | ||
| # | ||
| # proxy_buffering off: response CARs can be tens of MB and | ||
| # are content-addressed (verified end-to-end by the receiver). | ||
| # Buffering provides no value and would pile bytes up in | ||
| # nginx's worker memory under concurrent fetches. | ||
| # | ||
| # No client_max_body_size needed — the request body is the | ||
| # query string (`?arg=<cid>`); the bytes flow the other way. | ||
| location /api/v0/dag/export { | ||
| proxy_pass http://127.0.0.1:5001; | ||
| proxy_buffering off; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_read_timeout 300s; | ||
| proxy_send_timeout 300s; | ||
| proxy_pass_header Access-Control-Allow-Origin; | ||
| proxy_pass_header Access-Control-Allow-Methods; | ||
| proxy_pass_header Access-Control-Allow-Headers; | ||
| proxy_pass_header Access-Control-Expose-Headers; | ||
| } | ||
|
Comment on lines
+287
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For streaming large CAR files via |
||
|
|
||
| # Safe API proxy for content preloading (refs triggers fetch via bitswap) | ||
| location /api/v0/refs { | ||
| client_max_body_size 10M; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, Nginx buffers the entire request body in memory or on disk before forwarding it to the upstream server. For large CAR file uploads (up to 100MB), this introduces significant latency because Kubo cannot start processing/pinning the blocks until the upload to Nginx is fully complete. It also causes unnecessary disk I/O overhead on the proxy layer.
Disabling request buffering with
proxy_request_buffering off;and enablingproxy_http_version 1.1;allows Nginx to stream the request body directly to Kubo as it is received from the client.