Skip to content

Commit

Permalink
add builder interface for making servers (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Oct 2, 2024
1 parent f4b8430 commit 5f04943
Show file tree
Hide file tree
Showing 33 changed files with 864 additions and 420 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
check-style:
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,54 @@

https://github.com/oxidecomputer/dropshot/compare/v0.12.0\...HEAD[Full list of commits]

* https://github.com/oxidecomputer/dropshot/pull/1122[#1122] Adds a new `ServerBuilder` as the primary way of constructing a Dropshot server. This replaces `HttpServerStarter::new()` and `HttpServerStarter::new_with_tls()`. These older functions still exist for compatibility. They may be removed in an upcoming release, along with the `HttpServerStarter`.
+
In this release, using the builder interface is not very different from using these older functions. But as we look at adding new construction-time options (e.g., for API versioning), those will only be added to the builder.
+
The builder also provides structured errors rather than the `GenericError` provided by these older functions.
+
Most non-TLS callers were using `HttpServerStarter::new()` and then calling `start()` right away. In that case, you can replace:
+
```rust
HttpServerStarter::new(&config, api, private, &log).map_err(...)?.start()
```
+
with:
+
```rust
ServerBuilder::new(api, private, log).config(config).start().map_err(...)?
```
+
If you were using `HttpServerStarter::new_with_tls()`, you'd similarly replace:
+
```rust
HttpServerStarter::new_with_tls(&config, api, private, &log, tls).map_err(...)?.start()
```
+
with:
+
```rust
ServerBuilder::new(api, private, log).config(config).tls(tls).start().map_err(...)?
```
+
If you were _not_ invoking `start()` immediately before, you can still construct an intermediate starter object with `build_starter()`. If you were doing this:
+
```rust
let starter = HttpServerStarter::new(&config, api, private, &log).map_err(...)?;
...
starter.start()
```
+
Then you can now do:
+
```rust
let starter = ServerBuilder::new(api, private, log).config(config).build_starter().map_err(...)?;
...
starter.start()
```
+
We'd like to remove the `HttpServerStarter` altogether, so let us know if you're still using it for some reason.

== 0.12.0 (released 2024-09-26)

https://github.com/oxidecomputer/dropshot/compare/v0.11.0\...v0.12.0[Full list of commits]
Expand Down
Loading

0 comments on commit 5f04943

Please sign in to comment.