-
Notifications
You must be signed in to change notification settings - Fork 318
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
Update Rust guidelines for module layout #8490
Open
heaths
wants to merge
1
commit into
Azure:main
Choose a base branch
from
heaths:rust-creatables
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
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.
I worry that this makes the root a bit cluttered. Maybe it's ok for clients/models/enum types but for client method options do we think there's value in having them in the root? More often than not callers just pass
None
(at least this is the case in Go). What if we were to either leave them inclients
only, or put them in a separate module?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.
I'm open to it. The idea was to have all creatable in the root, but there's likely more client method options than request models. Well, unless the request models include a lot of sub-models like Cognitive would have. Hmm, now I'm starting to rethink this. Maybe we shouldn't export models from the root.
@RickWinter @JeffreyRichter what do you think? I mean, rust-analyzer should make light work of these either way and it does mitigate possibly shuffling models in an out (edge case, but definitely happens).
So, it'd be:
clients
just so all clients are always found there).clients
submodule only.models
.@analogrelay and @vincenttran-msft how do you feel about this?
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.
IMO it's cleaner.
I do still have reservations about client method options being in the root. What if we put them in the root IFF they contain modeled fields? I think it would help quiet down the noise, unless we expect callers to do something with the
method_options
field on a fairly routine basis.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.
Maybe, but I'm not too crazy about the subtleties here. I doubt customers would get the subtlety and I imagine I'll probably even forget after a time why some are re-exported from the root and others aren't.
What does Go do here? Or, IIRC, does it export everything from the root which, yes, is noisy. I do want to be less noisy, but also not introduce a bunch of subtlety that would likely be hard to maintain for various reasons and likely lost on customers anyway.
That said, but the reasons you brought up, maybe all client method options are only exported from
clients
. I think we still keep client options with their clients as those will likely get used more.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.
Yeah, client options stay with their client (e.g. for instantiable clients, its client options type would also go in the root).
Agreed on the subtleties. Keeping the client method options in
clients
is an improvement IMO since so many of them are essentially empty. And if customers hate it, we can always change it later before GA.In Go we dump everything in the root for two reasons.
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.
That's a good point. However, I think the same applies if we are to keep them in the
clients
module. With that being the case, do we likefoo_crate::clients::FooClientGetOptions
orfoo_crate::options::FooClientGet
better?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.
I prefer the latter just because it's clear. By default, rust-analyzer is going to import types so you eng up with
FooClientGet
which is not clear on face value what it does. "Options" being part of the name hopefully seems more obvious. It's also idiomatic:std
,tokio
, and many others have "***Options" types.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.
Good point, let's keep the
Options
suffix. So, do we want to keep them all in theclients
module then? Or do we want to put all client method options in some other module?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.
I think client options should be exported from
clients
but client method options should / could be exported from models. In a way, that's really what they are and I don't want to add a bunch of modules unless it makes a lot of sense to.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.
Ok I like this, let's start with that.