-
Notifications
You must be signed in to change notification settings - Fork 40
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
[WIP] example of trait-based Dropshot server #5653
Closed
sunshowers
wants to merge
5
commits into
main
from
sunshowers/spr/wip-example-of-trait-based-dropshot-server
Closed
[WIP] example of trait-based Dropshot server #5653
sunshowers
wants to merge
5
commits into
main
from
sunshowers/spr/wip-example-of-trait-based-dropshot-server
Conversation
This file contains 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
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
sunshowers
commented
Apr 29, 2024
path = "/sled-agents/{sled_id}", | ||
}] | ||
async fn sled_agent_get( | ||
rqctx: RequestContext<Self>, |
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.
Static dispatch is nicer because
- you don't have to prove that the trait is object-safe
- you can also add non-endpoint methods and other items to the trait
- you don't need to use async-trait, leading to a nicer IDE/rust-analyzer experience.
sunshowers
commented
Apr 29, 2024
Comment on lines
-70
to
-113
api.register(sled_agent_get)?; | ||
api.register(sled_agent_put)?; | ||
api.register(sled_firewall_rules_request)?; | ||
api.register(switch_put)?; | ||
api.register(rack_initialization_complete)?; | ||
api.register(cpapi_instances_put)?; | ||
api.register(cpapi_disks_put)?; | ||
api.register(cpapi_volume_remove_read_only_parent)?; | ||
api.register(cpapi_disk_remove_read_only_parent)?; | ||
api.register(cpapi_producers_post)?; | ||
api.register(cpapi_assigned_producers_list)?; | ||
api.register(cpapi_collectors_post)?; | ||
api.register(cpapi_artifact_download)?; | ||
|
||
api.register(cpapi_upstairs_repair_start)?; | ||
api.register(cpapi_upstairs_repair_finish)?; | ||
api.register(cpapi_upstairs_repair_progress)?; | ||
api.register(cpapi_downstairs_client_stop_request)?; | ||
api.register(cpapi_downstairs_client_stopped)?; | ||
|
||
api.register(saga_list)?; | ||
api.register(saga_view)?; | ||
|
||
api.register(ipv4_nat_changeset)?; | ||
|
||
api.register(bgtask_list)?; | ||
api.register(bgtask_view)?; | ||
api.register(bgtask_activate)?; | ||
|
||
api.register(blueprint_list)?; | ||
api.register(blueprint_view)?; | ||
api.register(blueprint_delete)?; | ||
api.register(blueprint_target_view)?; | ||
api.register(blueprint_target_set)?; | ||
api.register(blueprint_target_set_enabled)?; | ||
api.register(blueprint_regenerate)?; | ||
api.register(blueprint_import)?; | ||
|
||
api.register(sled_list_uninitialized)?; | ||
api.register(sled_add)?; | ||
api.register(sled_expunge)?; | ||
|
||
api.register(probes_get)?; | ||
|
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.
This is now automatically handled!
sunshowers
commented
Apr 29, 2024
Created using spr 1.3.6-beta.1
Closed in favor of #5844. |
sunshowers
deleted the
sunshowers/spr/wip-example-of-trait-based-dropshot-server
branch
May 31, 2024 18:52
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.
As discussed in #5247.
This PR converts the Nexus internal API to being a trait-based server, using the patched copy of Dropshot in oxidecomputer/dropshot#984. Thought converting a non-trivial but still relatively simple API would be able to give us a better sense of what we want the eventual API to look like.
The main advantage is that this lets you generate the internal API without having to compile all of Nexus. This is not only faster, I believe it completely solves issues where there are circular dependencies between different APIs. (For example, currently there's a Nexus internal API -> sled-agent -> Nexus internal API dependency, and changing the APIs can be extremely painful. With this approach, the API crates don't depend on each other -- only the implementation crates do.)
Another advantage is that it's pretty easy to write multiple implementations of the same API. So, for example, the simulated sled-agent can implement the same trait as the real one.