Skip to content
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

remove Arc around RequestContext #558

Merged
merged 57 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b38f14c
switch block-style to line-style comments
davepacheco Jan 9, 2023
3ac8c39
do not update rustfmt.toml too
davepacheco Jan 9, 2023
3b48121
fix websocket.rs (thanks @ahl!)
davepacheco Jan 9, 2023
9df46f7
move extractors and generic schema utilities out of handler.rs
davepacheco Jan 9, 2023
d9307c4
Merge remote-tracking branch 'origin/main' into extractor-move
davepacheco Jan 10, 2023
db9770f
fix style
davepacheco Jan 10, 2023
41a1cd6
WIP: making it work, need to rebase
davepacheco Jan 10, 2023
833920f
update changelog with some todo items
davepacheco Jan 10, 2023
067dd4a
prototype: remove request from RequestContext
davepacheco Jan 10, 2023
e394128
add XXX
davepacheco Jan 10, 2023
20460f6
remove Arc around RequestContext
davepacheco Jan 10, 2023
8ee3aa9
fix copyrights
davepacheco Jan 11, 2023
fb31831
review feedback
davepacheco Jan 11, 2023
1dff466
WIP: making it work, need to rebase
davepacheco Jan 10, 2023
1c7642b
update changelog with some todo items
davepacheco Jan 10, 2023
1673519
fix copyrights
davepacheco Jan 11, 2023
f77a40d
review feedback
davepacheco Jan 11, 2023
e962e2b
Merge branch 'merge-tmp' into exclusive-extractors
davepacheco Jan 11, 2023
f4dbd20
WIP: making it work, need to rebase
davepacheco Jan 10, 2023
ec810ea
update changelog with some todo items
davepacheco Jan 10, 2023
29c6b47
fix copyrights
davepacheco Jan 11, 2023
16d7ac3
review feedback
davepacheco Jan 11, 2023
c228e40
merge with "main"
davepacheco Jan 11, 2023
f68c794
Merge branch 'merge-with-main' into exclusive-extractors
davepacheco Jan 11, 2023
08c9a9a
fix style
davepacheco Jan 11, 2023
38324b4
update tests
davepacheco Jan 11, 2023
b200e10
remove TODO
davepacheco Jan 11, 2023
5bb93e7
rename tests
davepacheco Jan 11, 2023
aa6f16e
fix output
davepacheco Jan 11, 2023
0f956a5
copyright update was over-eager
davepacheco Jan 11, 2023
95afcad
Merge remote-tracking branch 'origin/main' into exclusive-extractors
davepacheco Jan 12, 2023
5979394
update CHANGELOG
davepacheco Jan 12, 2023
0c727b9
bump for major version
davepacheco Jan 12, 2023
5ec8a45
clean up docs, XXXs
davepacheco Jan 12, 2023
bda525f
could use another conversion
davepacheco Jan 12, 2023
fabe335
prototype: remove request from RequestContext
davepacheco Jan 10, 2023
f52ff85
add XXX
davepacheco Jan 10, 2023
21b0fbb
sync with "main" and "exclusive-extractors"
davepacheco Jan 12, 2023
99c6e33
Merge branch 'remove-rq-merge' into remove-rq
davepacheco Jan 12, 2023
951fb6c
rename the new pub type (requires moving the internal DTrace type wit…
davepacheco Jan 12, 2023
3a41c99
update changelog
davepacheco Jan 12, 2023
28fd310
remove TODO
davepacheco Jan 12, 2023
415c444
add compatibility method
davepacheco Jan 12, 2023
309f96d
typo
davepacheco Jan 12, 2023
3e2dbdb
fix dtrace probes
davepacheco Jan 12, 2023
185f7f8
websocket args should be last, too
davepacheco Jan 18, 2023
0f78f7d
Merge remote-tracking branch 'origin/main' into exclusive-extractors
davepacheco Jan 18, 2023
00193d1
found one straggler
davepacheco Jan 18, 2023
7847891
Merge remote-tracking branch 'origin/exclusive-extractors' into remov…
davepacheco Jan 18, 2023
4c090d2
Merge remote-tracking branch 'origin/remove-rq' into remove-arc-rqctx
davepacheco Jan 18, 2023
f21536c
draft CHANGELOG update
davepacheco Jan 18, 2023
7652cdf
fix warnings
davepacheco Jan 18, 2023
ed99787
fix signature
davepacheco Jan 18, 2023
6d85428
Merge commit '7edfeb9567614b2612addd9773d70341d268666e' into remove-a…
davepacheco Jan 19, 2023
cd97946
Merge remote-tracking branch 'origin/main' into remove-arc-rqctx-merge2
davepacheco Jan 19, 2023
4d44d6f
clippy
davepacheco Jan 19, 2023
7e1bfb6
missed updating the new tests
davepacheco Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ https://github.com/oxidecomputer/dropshot/compare/v0.8.0\...HEAD[Full list of co

=== Breaking Changes

// XXX-dap TODO need update here
// Extractor -> {Shared,Exclusive}Extractor
// type signature of from_request() changed
// both: accept &RequestContext instead of Arc
// now: no other change. future: exclusive one will get a hyper::Request
// exclusive extractors must appear last in the argument list

// XXX-dap TODO more updates for RawRequest extractor
// also update crate-level docs and other places we talk about TypedBody, etc.
// maybe add an example?

// XXX-dap TODO need update for removal of Arc around RequestContext

* https://github.com/oxidecomputer/dropshot/pull/504[#504] Dropshot allows TLS configuration to be supplied either by path or as bytes. For compatibility, the `AsFile` variant of `ConfigTls` contains the `cert_file` and `key_file` fields, and may be used similarly to the old variant.
* https://github.com/oxidecomputer/dropshot/pull/502[#502] Dropshot exposes a `refresh_tls` method to update the TLS certificates being used by a running server. If you previously tried to access `DropshotState.tls`, you can access the `DropshotState.using_tls()` method instead.
* https://github.com/oxidecomputer/dropshot/pull/540[#540] `ConfigDropshot` now uses a [`camino::Utf8PathBuf`](https://docs.rs/camino/1.1.1/camino/struct.Utf8PathBuf.html) for its file path. There is no change to the configuration format itself, just its representation in Rust.
Expand Down
4 changes: 2 additions & 2 deletions dropshot/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct CounterValue {
path = "/counter",
}]
async fn example_api_get_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
) -> Result<HttpResponseOk<CounterValue>, HttpError> {
let api_context = rqctx.context();

Expand All @@ -99,7 +99,7 @@ async fn example_api_get_counter(
path = "/counter",
}]
async fn example_api_put_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
update: TypedBody<CounterValue>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let api_context = rqctx.context();
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct AllPath {
unpublished = true,
}]
async fn static_content(
rqctx: Arc<RequestContext<FileServerContext>>,
rqctx: RequestContext<FileServerContext>,
path: Path<AllPath>,
) -> Result<Response<Body>, HttpError> {
let path = path.into_inner().path;
Expand Down
4 changes: 2 additions & 2 deletions dropshot/examples/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct CounterValue {
path = "/counter",
}]
async fn example_api_get_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
) -> Result<HttpResponseOk<CounterValue>, HttpError> {
let api_context = rqctx.context();

Expand All @@ -143,7 +143,7 @@ async fn example_api_get_counter(
path = "/counter",
}]
async fn example_api_put_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
update: TypedBody<CounterValue>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let api_context = rqctx.context();
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct AllPath {
unpublished = true,
}]
async fn index(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
path: Path<AllPath>,
) -> Result<Response<Body>, HttpError> {
Ok(Response::builder()
Expand Down
4 changes: 2 additions & 2 deletions dropshot/examples/module-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub mod routes {
path = "/counter",
}]
pub async fn example_api_get_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
) -> Result<HttpResponseOk<CounterValue>, HttpError> {
let api_context = rqctx.context();

Expand All @@ -105,7 +105,7 @@ pub mod routes {
path = "/counter",
}]
pub async fn example_api_put_counter(
rqctx: Arc<RequestContext<ExampleContext>>,
rqctx: RequestContext<ExampleContext>,
update: TypedBody<CounterValue>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let api_context = rqctx.context();
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/module-shared-context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub struct CounterValue {
path = "/counter",
}]
pub async fn example_api_get_counter(
rqctx: Arc<RequestContext<Arc<ExampleContext>>>,
rqctx: RequestContext<Arc<ExampleContext>>,
) -> Result<HttpResponseOk<CounterValue>, HttpError> {
let api_context = rqctx.context();

Expand Down
6 changes: 3 additions & 3 deletions dropshot/examples/multiple-servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ struct ServerDescription {
path = "/servers",
}]
async fn api_get_servers(
rqctx: Arc<RequestContext<MultiServerContext>>,
rqctx: RequestContext<MultiServerContext>,
) -> Result<HttpResponseOk<Vec<ServerDescription>>, HttpError> {
let api_context = rqctx.context();

Expand All @@ -285,7 +285,7 @@ struct PathName {
path = "/servers/{name}",
}]
async fn api_start_server(
rqctx: Arc<RequestContext<MultiServerContext>>,
rqctx: RequestContext<MultiServerContext>,
path: Path<PathName>,
body: TypedBody<SocketAddr>,
) -> Result<HttpResponseCreated<ServerDescription>, HttpError> {
Expand Down Expand Up @@ -313,7 +313,7 @@ async fn api_start_server(
path = "/servers/{name}",
}]
async fn api_stop_server(
rqctx: Arc<RequestContext<MultiServerContext>>,
rqctx: RequestContext<MultiServerContext>,
path: Path<PathName>,
) -> Result<HttpResponseDeleted, HttpError> {
let api_context = rqctx.context();
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/pagination-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct ProjectPage {
path = "/projects"
}]
async fn example_list_projects(
rqctx: Arc<RequestContext<BTreeMap<String, Project>>>,
rqctx: RequestContext<BTreeMap<String, Project>>,
query: Query<PaginationParams<EmptyScanParams, ProjectPage>>,
) -> Result<HttpResponseOk<ResultsPage<Project>>, HttpError> {
let pag_params = query.into_inner();
Expand Down
6 changes: 3 additions & 3 deletions dropshot/examples/pagination-multiple-resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn scan_params(p: &WhichPage<ExScanParams, ExPageSelector>) -> ExScanParams {
path = "/projects"
}]
async fn example_list_projects(
rqctx: Arc<RequestContext<DataCollection>>,
rqctx: RequestContext<DataCollection>,
query: Query<PaginationParams<ExScanParams, ExPageSelector>>,
) -> Result<HttpResponseOk<ResultsPage<Project>>, HttpError> {
let pag_params = query.into_inner();
Expand All @@ -184,7 +184,7 @@ async fn example_list_projects(
path = "/disks"
}]
async fn example_list_disks(
rqctx: Arc<RequestContext<DataCollection>>,
rqctx: RequestContext<DataCollection>,
query: Query<PaginationParams<ExScanParams, ExPageSelector>>,
) -> Result<HttpResponseOk<ResultsPage<Disk>>, HttpError> {
let pag_params = query.into_inner();
Expand All @@ -210,7 +210,7 @@ async fn example_list_disks(
path = "/instances"
}]
async fn example_list_instances(
rqctx: Arc<RequestContext<DataCollection>>,
rqctx: RequestContext<DataCollection>,
query: Query<PaginationParams<ExScanParams, ExPageSelector>>,
) -> Result<HttpResponseOk<ResultsPage<Instance>>, HttpError> {
let pag_params = query.into_inner();
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/pagination-multiple-sorts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn page_selector_for(
path = "/projects"
}]
async fn example_list_projects(
rqctx: Arc<RequestContext<ProjectCollection>>,
rqctx: RequestContext<ProjectCollection>,
query: Query<PaginationParams<ProjectScanParams, ProjectScanPageSelector>>,
) -> Result<HttpResponseOk<ResultsPage<Project>>, HttpError> {
let pag_params = query.into_inner();
Expand Down
6 changes: 3 additions & 3 deletions dropshot/examples/petstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct PathParams {
}]
/// Get the pet with the specified ID
async fn get_pet_by_id(
rqctx: Arc<RequestContext<()>>,
rqctx: RequestContext<()>,
path_params: Path<PathParams>,
) -> Result<HttpResponseOk<Pet>, HttpError> {
let pet = Pet {
Expand All @@ -94,7 +94,7 @@ async fn get_pet_by_id(
}]
/// Add a new pet to the store
async fn update_pet_with_form(
rqctx: Arc<RequestContext<()>>,
rqctx: RequestContext<()>,
body: TypedBody<Pet>,
) -> Result<HttpResponseOk<()>, HttpError> {
unimplemented!()
Expand Down Expand Up @@ -125,7 +125,7 @@ struct FindByTagsPageSelector {
}]
/// Find pets by tags
async fn find_pets_by_tags(
rqctx: Arc<RequestContext<()>>,
rqctx: RequestContext<()>,
query: Query<
PaginationParams<FindByTagsScanParams, FindByTagsPageSelector>,
>,
Expand Down
9 changes: 4 additions & 5 deletions dropshot/examples/request-headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//!
//! The headers accessed here will not be recorded as inputs in the OpenAPI
//! spec. This is not currently supported out-of-the-box with Dropshot, but it
//! could be done by implementing you're own `Extractor` that pulls the headers
//! out, similar to what's done here.
//! could be done by implementing you're own `SharedExtractor` that pulls the
//! headers out, similar to what's done here.
//!
//! This example is based on the "basic.rs" one. See that one for more detailed
//! comments on the common code.
Expand Down Expand Up @@ -46,11 +46,10 @@ async fn main() -> Result<(), String> {
path = "/header-example-generic",
}]
async fn example_api_get_header_generic(
rqctx: Arc<RequestContext<()>>,
rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<String>, HttpError> {
let request = rqctx.request.lock().await;
// Note that clients can provide multiple values for a header. See
// http::HeaderMap for ways to get all of them.
let header = request.headers().get("demo-header");
let header = rqctx.request.headers().get("demo-header");
Ok(HttpResponseOk(format!("value for header: {:?}", header)))
}
2 changes: 1 addition & 1 deletion dropshot/examples/schema-with-example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn main() -> Result<(), String> {
}]
/// Get a foo
async fn get_foo(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<Foo>, HttpError> {
let foo = foo_example();
Ok(HttpResponseOk(foo))
Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/self-referential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct CounterValue {
path = "/counter",
}]
async fn example_api_get_counter(
rqctx: Arc<RequestContext<Arc<ExampleContext>>>,
rqctx: RequestContext<Arc<ExampleContext>>,
) -> Result<HttpResponseOk<CounterValue>, HttpError> {
let api_context = rqctx.context();

Expand Down
2 changes: 1 addition & 1 deletion dropshot/examples/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct QueryParams {
path = "/counter",
}]
async fn example_api_websocket_counter(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
upgraded: WebsocketConnection,
qp: Query<QueryParams>,
) -> dropshot::WebsocketChannelResult {
Expand Down
6 changes: 3 additions & 3 deletions dropshot/examples/well-tagged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dropshot::{
tags = ["simpsons"],
}]
async fn get_homerism(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<String>, HttpError> {
unimplemented!()
}
Expand All @@ -30,7 +30,7 @@ async fn get_homerism(
tags = ["simpsons"],
}]
async fn get_barneyism(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<String>, HttpError> {
unimplemented!()
}
Expand All @@ -41,7 +41,7 @@ async fn get_barneyism(
tags = ["futurama"],
}]
async fn get_fryism(
_rqctx: Arc<RequestContext<()>>,
_rqctx: RequestContext<()>,
) -> Result<HttpResponseOk<String>, HttpError> {
unimplemented!()
}
Expand Down
Loading