-
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
[nexus] Break up db model into multiple files #1013
Conversation
use std::net::SocketAddrV6; | ||
use uuid::Uuid; | ||
|
||
// TODO: Break up types into multiple files |
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.
On the bright side, this is done now
By line count, the other heavy offenders are:
If we're happy with the direction of this PR, I think we'd benefit from breaking these up into smaller files too. This is subjective, but IMO, having smaller files improves discoverability while also making decoupling a bit more natural. |
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.
long overdue, big improvement. let's do the other ones
Thanks for looking at this. Yeah, some of the files have definitely gotten very large. At the same time, I find it a lot harder to discover and grok a large number of tiny files than a smaller number of larger files, especially if the latter are well organized. For example, this PR has almost four dozen files now in nexus/src/db/model, and the relationships between related models are gone. "region.rs" is next to "role_assignment.rs" but they have nothing to do with each other, while "user_builtin.rs" (which is only 23 lines) is not near other IAM-related things. What do you think of grouping these a little more thematically, like maybe "iam.rs", "networking.rs", etc? |
Sure, that would be okay with me. I think there are a number of ways to resolve the "grouping":
|
I think I like the prefix idea better than the bigger files. |
I prefer bigger files because they can be structured with a logical narrative instead of strictly alphabetical. When I'm coming up to speed on something I like to pull up a big file, read it top to bottom (ideally starting with a big subsystem block comment), and feel like I understand the structure of the thing. |
Another option is additional layers of hierarchy in the module structure. For example, |
@bnaecker I like that idea - it's a nice compromise, because it lets those of us who like small files keep them, while it also provides a natural grouping (by directory) in which we could include, for example, area-specific documentation |
I don't know where to discuss the other ones in flight before we go ahead and do them... Regarding nexus.rs: is it worth rethinking this one? The original idea was to have a sort of business logic layer between the datastore and the HTTP endpoints that could be shared with interfaces besides than the HTTP endpoints. The best case for something like this is the logic around At the same time it feels like there's a ton of boilerplate here where this layer isn't adding anything. For the various CRUD functions that are all just (1) use LookupPath to look up a resource and then (2) call a datastore function to do something with that resource, I wonder if we're better off doing that stuff directly from the HTTP entrypoints. The datastore layer exposes a pretty low-level interface atop the database that attempts to ensure database-level integrity, but doesn't know about higher-level application-level concerns. Examples: the idea of an |
I'm ambivalent about the |
FWIW, I've filed #1016 so we can discuss further, if folks want to redirect conversation there. Apologies for not making an issue earlier! |
Crucible changes: test-crudd can collect more info, test_up can be gentle (#997) Decrypt without holding the downstairs lock (#1021) Add raw file backend (#991) Don't hold the Downstairs lock while doing encryption (#1019) Antagonize the Crucible Agent (#1011) The Pantry should reject non-block sized writes (#1013) Propolis changes: Just the commit that updates Crucible
Crucible changes: test-crudd can collect more info, test_up can be gentle (#997) Decrypt without holding the downstairs lock (#1021) Add raw file backend (#991) Don't hold the Downstairs lock while doing encryption (#1019) Antagonize the Crucible Agent (#1011) The Pantry should reject non-block sized writes (#1013) Propolis changes: make headroom for linux virtio/9p client impl (#565) Guarantee Tokio access for Entity methods --------- Co-authored-by: Alan Hanson <[email protected]>
nexus/src/db/model.rs
intonexus/src/db/model/mod.rs