Skip to content
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 endpoint and endpoint test generation to module system #81

Merged
merged 14 commits into from
May 5, 2017

Conversation

ChuntaoLu
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Apr 28, 2017

Coverage Status

Coverage increased (+0.2%) to 64.962% when pulling 6a58de0 on lu.module into d61d33f on master.

@coveralls
Copy link

coveralls commented Apr 28, 2017

Coverage Status

Coverage increased (+0.3%) to 64.998% when pulling 67e92ff on lu.module into d61d33f on master.

module/module.go Outdated
)
}

n, err := file.Write(bytes)

if err != nil {
return errors.Wrapf(err, "Error writing to file %s", filePath)
return errors.Wrapf(err, "Error writing to file \"%s\"", filePath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a %q that will encode with the quotes. Aka %q is "%s"`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, good to know, replaced them

@coveralls
Copy link

coveralls commented Apr 28, 2017

Coverage Status

Coverage increased (+0.3%) to 64.998% when pulling 7a785ca on lu.module into d61d33f on master.

@ChuntaoLu ChuntaoLu force-pushed the lu.module branch 2 times, most recently from 047a0cb to 48bd0ec Compare May 1, 2017 23:12
@coveralls
Copy link

coveralls commented May 1, 2017

Coverage Status

Coverage increased (+0.2%) to 66.394% when pulling 48bd0ec on lu.module into 7868deb on master.

Copy link
Contributor

@Matt-Esch Matt-Esch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration for all module types is supposed to live in the "config:" key. The "endpoints" array needs to live on that config object. The endpoint generation modules should generate both endpoints and tests from that config.

Also I don't think it's that clean to move all of the endpoint config and template structs into the module_system.go file. That file is a clean expression of a) the module types, i.e. the first section describes the structure of the repository, and b) the generator implementation that calls into templates. I think the actual config structs should remain in the gateway.go file for now, and we should move them into separate files per module type later. I think the volume of code per module warrants that at this point.

@coveralls
Copy link

coveralls commented May 1, 2017

Coverage Status

Coverage increased (+0.2%) to 66.43% when pulling 48bd0ec on lu.module into 7868deb on master.

@ChuntaoLu
Copy link
Contributor Author

@Matt-Esch

The configuration for all module types is supposed to live in the "config:" key. The "endpoints" array needs to live on that config object. The endpoint generation modules should generate both endpoints and tests from that config.

I should have noted the config arrangement in this PR is tentative, the main focu was to add endpoint generation into the module system with minimum config structure change. As to the actual config structure, we should come up with a proper schema before diving into change those json files.

I think the actual config structs should remain in the gateway.go file for now,

Those config structs were originally in template.go, which is going away as the module system takes care of code generation. I agree with the point of what module_system.go files tries to tell, I don't think it matters too much where those structs are for now since things will surely gets moved around a lot.

@coveralls
Copy link

coveralls commented May 2, 2017

Coverage Status

Coverage increased (+0.1%) to 69.071% when pulling 2198b05 on lu.module into 2659814 on master.

func NewDefaultModuleSystem(
configDirName string,
middlewareConfig string,
h *PackageHelper,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered putting the middleware config information on the PackageHelper. To me it feels a bit weird to have these arguments here. Right now I have a codebase that I only generate clients in, and the change to this interface would now require me to care about non-existent middleware configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I didn't know a good way to get a hold of the middleware config, I know it feels awkward to pass in as arguments, it doesn't feel belong to PackageHelper either.

Copy link
Contributor

@Matt-Esch Matt-Esch May 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like it belongs in either place, but the PackageHelper gives us information about the structure of the package. With middlewares in this current mode, they are a permanent fixture of the package, which is arguably why the package helper does make some sense. It also has the benefit that existing consumers initialize the package helper in the current way and this configuration can be defaulted.

@@ -92,10 +100,68 @@ func NewDefaultModuleSystem(h *PackageHelper) (*module.System, error) {
)
}

// TODO: Register endpoint module class and type generators
middlewareSpecs := map[string]*MiddlewareSpec{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the middlewares need to be modeled as a dependency but we can think about that later. It might make sense to treat them as a global grab bag (i.e. a single module of middlewares)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I like them to be explicitly specified as an endpoint's dependencies, so module system can pick them up just like clients. But they are slightly different because middleware config may need to provide input for middlewares to work.

@coveralls
Copy link

coveralls commented May 4, 2017

Coverage Status

Coverage increased (+0.1%) to 69.047% when pulling f26ad2b on lu.module into b3925e0 on master.

@Matt-Esch
Copy link
Contributor

👍 lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants