-
Notifications
You must be signed in to change notification settings - Fork 578
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
feat: standardize plugin naming, add getMiddleware fn [WIP] #402
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Codecov Report
@@ Coverage Diff @@
## smithy-codegen #402 +/- ##
==================================================
+ Coverage 96.72% 96.97% +0.25%
==================================================
Files 69 69
Lines 1161 1158 -3
Branches 214 214
==================================================
Hits 1123 1123
+ Misses 38 35 -3
Continue to review full report at Codecov.
|
Can you keep the CHANGELOG untouched? So we have a clue on what they are renamed from. |
let _config_5 = UserAgentConfig.resolve(_config_4); | ||
super(_config_5); | ||
this.config = _config_5; | ||
super.use(AwsAuthConfig.getMiddleware(this.config)); |
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 not a fan of getMiddleware()
, because it doesn't give you a middleware. It in-fact mutates the client's middleware stack. Also the all namespace XXXConfig
doesn't make sense because they are not really Config
. I still prefer the naming convention of client config component's named XXXConfig
. If they have middleware to insert, then it should export a XXXPlugin
. If destroy method is required, then it should export a method called destroyXXX()
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 removed the Config
suffix and switched to resolveConfig
and setMiddleware
to make this more clear. Using the name for a plugin, along with same function for resolveConfig
, destroy
, etc will be easier to codegen.
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 not a fan of getMiddleware(), because it doesn't give you a middleware. It in-fact mutates the client's middleware stack.
Is this true? Or is this going to be true after some future changes? This code looks like it's getting a list of middleware to inject into this.use
by calling getMiddleware
.
I still prefer the naming convention of client config component's named XXXConfig. If they have middleware to insert, then it should export a XXXPlugin. If destroy method is required, then it should export a method called destroyXXX()
Can you give concrete examples?
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 code looks like it's getting a list of middleware to inject into this.use by calling getMiddleware
I updated the use
interface recently which takes in a function mutating the middleware stack, see here, and here.
A runtime plugin is not just a list of middleware, it may also include mutating existing middleware stack and even delete some middleware if exist. This interface allows more extensibility than only allowing injecting new middleware.
Using setMiddleware
here is better than getMiddleware
. I will propose getPlugin
as it better describe the function.
Can you give concrete examples?
AwsAuth
customization has input config interface, soClientConfiguration
containsAwsAuthInput
, andAwsAuth.Resolved
. TheresolveConfig
should also be called.AwsAuth
customization has middleware stack customization(runtime plugin), so client shoulduse the plugin
. But here I suggest renaming it tosuper.use(AwsAuth.getPlugin(this.config))
).AwsAuth
doesn't have adestroy
so takeProtocolConfig
as an example, because it contains handler. The clientdestroy()
will look like:
destroy(): void {
ClientProtocol.destroy(this.config);
}
The destroy
function will call the destroy function on this.config.protocol
and hence destroy the handler. The this.config
is supplied to function because destroyable resources are in the client's resolved config
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 updated the use interface recently which takes in a function mutating the middleware stack, see here, and here.
👍
Using setMiddleware here is better than getMiddleware
👍
I will propose getPlugin as it better describe the function.
I think setMiddleware
of updateMiddleware
makes more sense. It says exactly what the function does. getPlugin
doesn't convey anything really, and it makes the term "plugin" more ambiguous in the SDK. We need to be really deliberate with how we describe things across codegen and runtime packages.
AwsAuth customization has input config interface, so ClientConfiguration contains AwsAuthInput, and AwsAuth.Resolved. The resolveConfig should also be called.
Why the difference between AwsAuthInput
and AwsAuth.Resolved
? Seems like a strange pattern. If there's some technical limitation in IDEs, then we should standardize on AwsAuthInput
and AwsAuthResolved
instead to make this less surprising.
If we do that, then we should get rid of the namespacing altogether and do something like:
AwsAuthConfigInput
interfaceAwsAuthConfigResolved
interfaceresolveAwsAuthConfig()
functionupdateAwsAuthMiddleware()
function
My biggest gripe with the above code is that it's leaning way too much on convention and spreading the responsibility out across so many different disconnected things.
Alternatively we could have a different convention for bridging codegen and runtime code references. For example we could provide a set of interfaces that have generic parameters for the input type, resolved type, and methods for resolveConfig
and updateMiddleware
.
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.
Why the difference between AwsAuthInput and AwsAuth.Resolved? Seems like a strange pattern.
Yes. It is an IDE limitation. It makes sense to get rid of namespace.
I'm still a little concern about the updateAwsAuthMiddleware
. It sounds like it takes a parameter that is a middleware to be updated. In fact the Injectable
interface is the "Plugin" interface we expose(I think we should rename it to Pluggable
). The updateAwsAuthMiddleware()
is actually a getter of a Pluggable
, this is why I suggest getPlugin
.
we could provide a set of interfaces that have generic parameters for the input type, resolved type, and methods for resolveConfig and updateMiddleware.
I prefer using convention over interface because by using interface, these config and middleware plugins will be attached to a single object. If you import one of them in client, you import all of them. But for customizations that requires client config and middleware in the commands(there are many), we don't want to import middleware plugin in the client. This will increase the size of the client.
Basically the config and middleware plugin are better to be decoupled.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This PR has been replaced to #422 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Standardizes naming of plugins. Use
resolveConfig
andgetMiddleware
.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.