-
Notifications
You must be signed in to change notification settings - Fork 6
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
Decaf endpoints #223
Decaf endpoints #223
Conversation
gems/smithy/lib/smithy/anvil/templates/client/plugins/endpoint.erb
Outdated
Show resolved
Hide resolved
gems/smithy/lib/smithy/anvil/templates/client/plugins/endpoint.erb
Outdated
Show resolved
Hide resolved
gems/smithy/lib/smithy/anvil/views/client/endpoint_parameters.rb
Outdated
Show resolved
Hide resolved
|
||
# Endpoint BuiltInBinding | ||
class BuiltInBinding | ||
def initialize(id:, render_config:, render_build:, render_test_set:) |
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've just been using options = {} everywhere because of how easy it is to just pass options down the line without extracting keyword args... Not sure how you feel about that. I think I lean towards keyword args for required public interfaces.
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 - I think for required public interfaces I'd generally prefer keyword args. Since this is an extension point/public interface, I think keeping them as keywords make sense.
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 don't think this is public at all. Please just use options for vise usage. But I think these are better used as view classes now - since vise does not have any shape wrapping.
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.
These must be public - these are the extension point for users to add endpoint related bindings.
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've removed the classes and just using arrays/hashes.
[Vise::Endpoints::BuiltInBinding.new( | ||
id: 'SDK::Endpoint', | ||
render_config: proc do |_plan| | ||
<<-ADD_OPTION |
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've been using ~ with indentation. I think you can make this a method that takes option values. Custom options come from the endpoint params but static values for endpoint.
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 can switch to <<~
for indentation - I don't have a style preference on those.
What do you mean about having this method take option values. I'm not quite sure I understand.
In general, this needs to be fairly flexible to support all of our existing/future built ins (eg: account id).
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 still needs to be indented. What I was saying before was to have a method that is responsible for rending the config, but this is fine to hardcode endpoint for now. Eventually this will need to be a method.
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 is the correct indenting for it to render correctly in the generated code.
Why should this be a method? I think I'm still a little confused about that. Using a proc/callable is what lets a user define arbitrary configuration(s) that may apply for the builtin. I think thats perferable to coming up with a codegen time modeling of 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.
May want to run rubocop to fix some indentations.
|
||
attr_reader :scheme, :authority, :path, :normalized_path, :is_ip | ||
|
||
def as_json(_options = {}) |
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.
Curious to know why _options = {}
is necessary than omitting it. I'm guessing it is due to the way this class is used as a "wrapper" for URI?
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 question, I guess we could use *
or ...
instead to indicate it can take arguments, but doesn't use them.
Edit, I've updated to use just *
.
gems/smithy/lib/smithy/anvil/templates/client/plugins/endpoint.erb
Outdated
Show resolved
Hide resolved
gems/smithy/lib/smithy/anvil/views/client/endpoint_parameters.rb
Outdated
Show resolved
Hide resolved
[Vise::Endpoints::BuiltInBinding.new( | ||
id: 'SDK::Endpoint', | ||
render_config: proc do |_plan| | ||
<<-ADD_OPTION |
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 still needs to be indented. What I was saying before was to have a method that is responsible for rending the config, but this is fine to hardcode endpoint for now. Eventually this will need to be a method.
@@ -0,0 +1,319 @@ | |||
{ |
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.
Are there .smithy file equivalents we should copy in too?
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 guess - they're in AwsDrSeps. I'm not sure I like this mixed model.json/model.smithy we have going for our test fixtures, though I'm not quite sure what we should do.
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 find it easier to edit the model files in smithy IDL then generate the json with it, that's why both are there. We could require smithy cli and shell out to convert to AST and not have the json, but also having the json inspectable (in the folder) helps with writing generation.
# Conflicts: # Rakefile
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!
include_paths = [] | ||
tmp_dirs = [] | ||
Dir.glob('gems/smithy/spec/fixtures/endpoints/*/model.json') do |model_path| | ||
test_name = model_path.split('/')[-2] |
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.
Is there a better way to express this one?
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.
Do you mean the model_path.split('/')[-2]
part? I could do model_path.split('/').last(2).first
instead, but that felt worse. Alternatively we coudl use regex to extract it, but I think splitting on / is simpler here.
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.
Was thinking in terms of readability. What exactly is extracted? It's otherwise fine.
@@ -24,6 +24,7 @@ def forge | |||
|
|||
private | |||
|
|||
# rubocop:disable Metrics/AbcSize |
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 added the methods here to solve this but I guess it was just deferred. Is there a way to solve this one? Maybe if enumerator is passed to a method and that method does the yielding? Otherwise I guess it's fine to just ignore this one as it's a giant list.
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, its just a list so I don't think rubucop is useful for that... We could solve it by breaking it into even more methods, but I dont think that really helps readability.
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. In that case the multimethods are kinda unnecessary.
e.yield "lib/#{@gem_name}/plugins/endpoint.rb", render_endpoint_plugin | ||
|
||
e.yield 'spec/spec_helper.rb', render_spec_helper | ||
e.yield 'spec/endpoint_provider_spec.rb', render_endpoint_provider_spec |
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 by convention this should still be spec/gemname/specs
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.
Was following what we had in V3, but I can update.
def endpoint_built_in_bindings | ||
{ | ||
'SDK::Endpoint' => { | ||
# Text indenting is used in generated view. |
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 would be better if indenting was relative instead of absolute here. So, using <<~ADD_OPTION
with one level of indenting, then in our view, apply the current indenting level plus this one level.
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 struggling with this because of the multiline text. Is there a way to have erb views indent multiline text?
Description of changes:
Changes in
smithy-client
:Endpoints
plugin - this is instead code generated per service.Changes in
smithy
:Not part of this PR (future work):
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.