Repository navigation
[nexus] Break up nexus.rs into app/ directory. - #1023
Conversation
|
As of 4036456 , this splits the previously-largest-rust-file-in-Omicron |
|
Definitely into the general idea. Glad to see the former |
|
|
||
| // TODO-robustness we should have a limit on how many sled agents there can | ||
| // be (for graceful degradation at large scale). | ||
| pub async fn upsert_sled( |
There was a problem hiding this comment.
I gather we've grouped things by the noun that they seem to relate to (e.g., "sled" here). I find it a little weird to combine the internal vs. external functions in this way. That is, upsert_sled is eventually going to do a whole bunch of work in response to the new information that a Sled Agent has started up...that all feels pretty unrelated to the public-facing sled CRUD functions.
sled_allocate() is different than both of these.
I felt a similar dissonance around saga.rs, where execute_saga() really has little to do with the saga fetch/list functions.
I don't know what else to suggest, though. Maybe a better structure will emerge when we flesh these things out more. (e.g., maybe upsert_sled will eventually become part of a stationkeeping submodule that monitors the rack's health and takes appropriate action as data comes in).
There was a problem hiding this comment.
I'm still a little split on this - I'm not sure if this layer even needs to make a distinction of "internal" vs "external" APIs. After all, the internal_api and external_api directories in Nexus are sorta making this distinction for us, in a literal sense.
After all, if both interfaces (external and internal) poke at a sled, what's the issue with grouping them together? They'll be accessing the same underlying structures, and the implementations may end up needing to be aware of each other. As an example: The "notify_instance_changed" implementation is internal (called only by sled agent) but the external "change instance state" methods are aware of the sled agent "owning" instance state data.
Definitely agree though, we can keep iterating on this - this is my first cut at grouping things by related functionality, but this will undoubtedly keep changing.
Part of #1016
nexus.rs- really, theimpl Nexus- into individual files within thenexus/src/appsubdirectory. A module-level comment in each file explains scope.project_create_instance) functions within the same file. This ended up kinda non-intuitive, since object creation is frequently much more about the "object being created" than it is about the container. Instead, I opted for a more nuanced "grouped-by-relevance" approach, which tries to keep "all logic related to instances" in "instance.rs", "all logic related to disks" in "disk.rs", etc.