-
Notifications
You must be signed in to change notification settings - Fork 66
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
Move clients init file generate to module system [breaking change] #99
Conversation
I think @Matt-Esch should be reviewer for this. I believe he had some plans to generalize the "clients init" without adding a new config file by generating |
@Raynos yeah, the config file feels unnecessary, it's currently a hack to tick the module system for a green pass, but might be useful in the future. I requested @Matt-Esch to review the change as well. I want you and @stevededalus to be aware of the breaking change in case this PR goes in. |
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.
Generally looks good to me. We discussed how this is going to change to a more structured approach per binary, but this is a reasonable next step.
codegen/gateway.go
Outdated
return nil, errors.Errorf( | ||
"client config (%s) must have customImportPath field for type custom", jsonFile, | ||
) | ||
fields := []string{ |
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 this should be a declared outside of the function if it is static.
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, done.
codegen/module_system.go
Outdated
@@ -134,6 +134,24 @@ func NewDefaultModuleSystem( | |||
) | |||
} | |||
|
|||
if err := system.RegisterClass("clients", module.Class{ |
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 an interesting way to create a global clients object. You might want to pick a slightly more obvious variant of name here because client vs clients is pretty hard to distinguish at a glance. Nice to see that the SingleModule type actually still works because it isn't used anywhere right now.
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 find it neat to be able to leverage the SingleModule
type for the initialization piece. 👍
Regarding the naming, I guess we can keep it as is for now since the config is one time only and doesn't really provide much information.
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 a great step towards the end goal.
At some point we can get rid of the "clients" module config.
This PR moves the client init file generation into the module system.
Breaking: with this change, a
clients-config.json
file is required in theclients
directory. And to tame the module system, the config file must have following fields as in https://github.com/uber/zanzibar/pull/99/files#diff-4eeffff9fb08e6dff5f0056d5106f422: