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

Minimize API surface in anticipation of gorelease #1146

Merged
merged 4 commits into from
Mar 4, 2020

Conversation

johanbrandhorst
Copy link
Collaborator

The grpc-gateway was created long before things like go modules semver and with little concern for internal package management. This unfortunately means that technically the API surface is enormous, however most of these packages are not really considered part of the public API.

This change moves everything that isn't part of the public API under various internal folder structures. This is obviously technically a breaking change, but I'm hoping we can get away with saying that our users really shouldn't have been importing these things anyway if any of them have been. I'm happy to discuss any concerns.

The end goal of this migration is to be able to use https://godoc.org/golang.org/x/exp/cmd/gorelease to ensure API stability across minor patches. The current structure prohibits this (because we make breaking changes to the examples all the time).

CC @achew22 @tmc @ivucica

@johanbrandhorst johanbrandhorst changed the title Minimize API surface in anticipation for gorelease Minimize API surface in anticipation of gorelease Mar 2, 2020
@achew22
Copy link
Collaborator

achew22 commented Mar 2, 2020

I'm extremely supportive of this change. Thank you for taking the initiative

@ivucica
Copy link
Collaborator

ivucica commented Mar 2, 2020

I am basically ok with this. Some tests are failing. I'll try to review this some time this week. Poke me using some out-of-band channel if I forget about it.

@johanbrandhorst johanbrandhorst force-pushed the add-gorelease branch 3 times, most recently from 9e8cc3c to 44ae41b Compare March 4, 2020 18:04
This is necessary as part of adding gorelease to our CI.
These packages could otherwise be considered part of our public API.
This will break users who are importing these examples in their own
projects.
This helps remove public API surface
This reduces our API surface
@codecov-io
Copy link

Codecov Report

Merging #1146 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1146      +/-   ##
==========================================
- Coverage   53.78%   53.74%   -0.05%     
==========================================
  Files          42       42              
  Lines        4211     4211              
==========================================
- Hits         2265     2263       -2     
- Misses       1698     1701       +3     
+ Partials      248      247       -1
Impacted Files Coverage Δ
examples/internal/server/flow_combination.go 0% <ø> (ø)
examples/internal/server/unannotatedecho.go 0% <ø> (ø)
examples/internal/server/responsebody.go 0% <ø> (ø)
examples/internal/server/a_bit_of_everything.go 0% <ø> (ø)
examples/internal/server/non_standard_names.go 0% <ø> (ø)
internal/descriptor/grpc_api_service.go 0% <ø> (ø)
...-gen-grpc-gateway/internal/gengateway/generator.go 38.61% <ø> (ø)
protoc-gen-swagger/internal/genswagger/types.go 0% <ø> (ø)
internal/httprule/parse.go 86.32% <ø> (ø)
examples/internal/server/main.go 0% <ø> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df4ff8d...7e41527. Read the comment docs.

@johanbrandhorst
Copy link
Collaborator Author

There seems to be a consensus that we should try this and see if it angers any users. Here goes!

@johanbrandhorst johanbrandhorst merged commit db7fbef into master Mar 4, 2020
@johanbrandhorst johanbrandhorst deleted the add-gorelease branch March 4, 2020 19:28
@karelbilek
Copy link

why did not grpc-gateway bump version to v2 when doing this? It did break backward compatibility and one of our modules broke, because it imported httprule.

this is why v2 exists. grpc-gateway should have bumped that :(

I agree with the reason of doing this (reducing the public API), but it should change major version and thus import path when doing it

@karelbilek
Copy link

karelbilek commented Mar 11, 2020

see https://blog.golang.org/v2-go-modules and https://github.com/golang/go/wiki/Modules - modules should be backwards compatible or change import path

I realize this is why this PR exists in the first place (to be able to track breaking changes), but it is still a massive breaking change in itself :(

@johanbrandhorst
Copy link
Collaborator Author

Hi @karel-3d, in principle I agree with you, but we wanted to see how much we could get away with doing without bumping to v2 yet. If you have a dependency that depends on httprule, I can move it back into the public API and make a new release (see #1154 and #1161). Could you raise an issue?

@karelbilek
Copy link

@johanbrandhorst hey sorry for the little confrontational tone at first, it was a bit angry at first :) but makes sense, and it's not that popular import so I get it

anyway I made an issue

#1168

adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
* Move examples under internal to avoid importing

This is necessary as part of adding gorelease to our CI.
These packages could otherwise be considered part of our public API.
This will break users who are importing these examples in their own
projects.

* Rename imports and regenerate files

* Make generator internals private

This helps remove public API surface

* Move codegenerator package to internal

This reduces our API surface
@johanbrandhorst johanbrandhorst mentioned this pull request Apr 20, 2020
13 tasks
pull bot pushed a commit to BuildingRobotics/grpc-gateway that referenced this pull request Apr 29, 2020
* Move examples under internal to avoid importing

This is necessary as part of adding gorelease to our CI.
These packages could otherwise be considered part of our public API.
This will break users who are importing these examples in their own
projects.

* Rename imports and regenerate files

* Make generator internals private

This helps remove public API surface

* Move codegenerator package to internal

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

Successfully merging this pull request may close these issues.

6 participants