-
Notifications
You must be signed in to change notification settings - Fork 55
refactor!: require a resolved configuration #351
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
Conversation
…Config; removing SigningRegion from config properties; add placeholders for loading config
…solver and cred provider to be required with a default
kggilmer
left a comment
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.
The cleanup around nullability in regions and CPs is great, nice work!
|
|
||
| private val overrideServiceCompanionObjectWriter = SectionWriter { writer, _ -> | ||
| // override the service client companion object for how a client is constructed | ||
| val serviceSymbol: Symbol = writer.getContextValue(ServiceGenerator.ServiceInterfaceCompanionObject.ServiceSymbol) |
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.
Nice!
| write("") | ||
| dokka { | ||
| write("Construct a [${serviceSymbol.name}] by resolving the configuration from the current environment.") | ||
| write("NOTE: If you are constructing multiple clients it is more efficient to construct an") |
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.
suggestion
Perhaps this would be better to leave out the bit about efficiency and just say that config can be shared, as customers may have other reasons or ideas for why they want to share configurations unrelated to efficiency.
NOTE: If you are using multiple AWS service clients you may wish to share the configuration among them
by constructing an [#Q] and passing it to each client upon construction.
ianbotsf
left a comment
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.
Looks pretty good!
My chief remaining concern is the verbosity of loadFromEnvironment as a name. While I could live with it if no one else shares the concern, I'd like to propose the following shorter alternatives (which may have other downsides):
fromEnvironment: matches the more typical factory method pattern of starting with "from"detect/automatic/autoDetect: implies hands-off configuration based on available local contextdefault(😛): pragmatically acknowledges that this will be the predominant use case (esp. given EC2, Lambda, and other compute environments where config is present)
| */ | ||
| public val credentialsProvider: CredentialsProvider | ||
|
|
||
| public companion object {} |
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.
Question: Why does AwsClientConfig need a public empty companion object?
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.
It's extended in aws-config
| val awsClientConfigSymbol = buildSymbol { | ||
| name = "AwsClientConfig" | ||
| namespace(AwsKotlinDependency.AWS_TYPES, subpackage = "client") |
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.
Question: Why not reuse the symbol in AwsRuntimeTypes?
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 only human Ian, accidents do still happen 😛
Will fix
| constantValue = """"$sigv4ServiceName"""" | ||
| propertyType = ClientConfigPropertyType.ConstantValue(""""$sigv4ServiceName"""") |
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.
Nit: Using dq may be cleaner:
propertyType = ClientConfigPropertyType.ConstantValue(sigv4ServiceName.dq())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.
Agreed, this was copy pasta, will update.
Sure, now is the time to get it right 😉 Ok so I don't love I think my preference lands on one of:
While |
IMO there are (at least) two properties of this call that customers would care about knowing of:
So a concise name that coveys these two properties in my mind is the original, |
The "substantial work" possibility is not the majority use case is it? It seems to me the majority use case is "a couple of local property lookups". To me, the possibility of greater work is already conveyed by My approval's on the PR so I can live with whatever we decide, including |
IMO it doesn't matter as long as it's possible. The idea is to eliminate unwanted surprises. That this call may read from disk or network predicated on factors outside of the program itself I think warrants the extra word. I am not sure Regarding suspension, we have it everywhere and IMO that in itself is not a clear indicator. |
For posterity: we discussed offline and decided on To quote Kyle:
|
Issue #
fixes smithy-kotlin#484
sibling: smithy-lang/smithy-kotlin#504
Description of changes
This PR updates the way AWS SDK clients are constructed such that configuration MUST be resolved at instantiation. This means that properties like
region,credentialsProvider,endpointResolver, etc are required and non-nullable. This PR adds several ways to get to this resolved state:suspend)suspend)suspend)Example of constructing a client:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.