Repository navigation
Keep query parameters on every page of a paginated stream - #1470
Open
Indian-boult wants to merge 2 commits into
Open
Indian-boult wants to merge 2 commits into
Indian-boult wants to merge 2 commits into
Conversation
The positional `_stream` method and the builder's `stream` set every query parameter except `limit` to None after the first page. Dropshot documents a second `Query` extractor next to `PaginationParams` for query parameters besides the pagination ones, and those must be sent with every page. Omicron's `silo_metric`, `system_metric`, `alert_class_list` and `alert_delivery_list` take one, so a stream of one project's metrics in oxide.rs returned that project's measurements on the first page and silo-wide measurements after it. Dropshot reads a request with a `page_token` as the next page and ignores the scan parameters, so every query parameter can go out on every page. The positional stream now passes them through, and the builder template resets only `page_token`. test_stream_pagination_extra_params runs a dropshot server whose endpoint filters with a second `Query`, and fails on main.
The comment said page_token may not be sent with other query parameters, which the stream code no longer assumes. Every query parameter now goes out on every page, and dropshot ignores the scan parameters when page_token is present.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The positional
_streammethod and the builder'sstreamset every query parameter exceptlimittoNoneafter the first page. Dropshot documents a secondQueryextractor next toPaginationParamsfor query parameters besides the pagination ones. Its docs say the scan parameters travel in the page token, and that required extra parameters must be supplied on each invocation. An optional extra parameter is read from each request the same way, so leaving it off a later page reads asNone. Omicron uses that forsilo_metric,system_metric,alert_class_listandalert_delivery_list. In the oxide.rs SDK at 621f533, thesilo_metricstream setsproject: Ok(None)for every page after the first, so streaming one project's metrics returns that project's measurements on the first page and silo-wide measurements after it, with no error. The alert lists lose their filters the same way.Dropshot treats a request that carries a
page_tokenas the next page and ignores the scan parameters, indeserialize_whichpage, and its own test sends both together. So every query parameter can go out on every page. The positional stream now passes them all through, and the builder template keeps them and resets onlypage_token, which each step fills in.test_stream_pagination_extra_paramsintest_specific.rsruns a dropshot server whose endpoint takes a secondQuerythat keeps only even numbers. On main both streams return the even numbers on the first page and every number after it. With the change both return only the even numbers, and the existingtest_stream_paginationstill passes. In the nexus outputs the positional streams pass every parameter through, and the builder streams stop resettingsort_byin 37 streams,organizationin 4,projectin 3, andstart_timeandend_timeindisk_metrics_list. Dropshot ignoressort_byon later pages. A comment indropshot_paginationstill saidpage_tokenmay not be sent with other query parameters, so it now says what the stream does. Streams are still generated only when every query parameter is optional. That check could be relaxed now, but I left it alone here.#1463 adds a line just above the builder's step parameters in
method.rs, so whichever of the two lands second needs a small rebase.cargo fmt --checkwith nightly, the build and test steps on stable and 1.97, the trybuild tests and the no-default-features build pass. Once a release has this, regenerating oxide.rs picks it up for the CLI.