Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

feat: add DIREGAPIC support for PHP #3305

Merged
merged 14 commits into from
Dec 8, 2020
Merged

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented Nov 10, 2020

Resubmission of #3301 from origin so all tests pass

  • Adds supportsGrpcTransport, which returns false when transport_protocol is set to REST
  • Modifies PHP GAPIC to:
    • ensure documentation for transport and transportConfig service clients options omit grpc
    • omit gcpApiConfigPath config in getClientDefaults
    • omit importing any grpc-related classes
    • Adds defaultTransport and getSupportedTransport functions to override the transport verification functionality in google/gax
  • Adds new baseline test for DIREGAPIC PHP
  • Updates PHP bazel rules to allow for REST transport

@bshaffer bshaffer requested a review from a team as a code owner November 10, 2020 22:31
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 10, 2020
@codecov
Copy link

codecov bot commented Nov 10, 2020

Codecov Report

Merging #3305 (3886997) into master (994ffa2) will increase coverage by 0.00%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3305   +/-   ##
=========================================
  Coverage     87.13%   87.14%           
- Complexity     6115     6120    +5     
=========================================
  Files           495      495           
  Lines         24159    24172   +13     
  Branches       2634     2637    +3     
=========================================
+ Hits          21051    21064   +13     
  Misses         2242     2242           
  Partials        866      866           
Impacted Files Coverage Δ Complexity Δ
...sformer/csharp/CSharpGapicUnitTestTransformer.java 96.89% <ø> (ø) 21.00 <0.00> (ø)
...n/transformer/java/JavaSurfaceTestTransformer.java 90.84% <ø> (ø) 34.00 <0.00> (ø)
...gle/api/codegen/viewmodel/DynamicLangXApiView.java 77.77% <ø> (ø) 13.00 <0.00> (ø)
...en/transformer/php/PhpGapicSurfaceTransformer.java 93.02% <87.50%> (-0.45%) 46.00 <1.00> (+3.00) ⬇️
...e/api/codegen/transformer/TestCaseTransformer.java 98.60% <100.00%> (ø) 56.00 <3.00> (+1.00)
...nsformer/nodejs/NodeJSGapicSurfaceTransformer.java 100.00% <100.00%> (ø) 29.00 <0.00> (ø)
.../transformer/py/PythonGapicSurfaceTransformer.java 99.58% <100.00%> (+<0.01%) 43.00 <0.00> (ø)
.../transformer/ruby/RubyGapicSurfaceTransformer.java 99.29% <100.00%> (+<0.01%) 46.00 <0.00> (ø)
...pi/codegen/transformer/MockServiceTransformer.java 93.10% <0.00%> (+3.44%) 15.00% <0.00%> (+1.00%)

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 994ffa2...3886997. Read the comment docs.

Copy link
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

Looking good! Only nits so far, but please wait for @vam-google to TAL.

namer.getAndSaveNicknameForGrpcClientTypeName(
context.getImportTypeTable(), context.getInterfaceModel());
apiImplClass.grpcClientTypeName(grpcClientTypeName);
if (supportsGrpcTransport()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a comment before this if block making it explicitly that we're generating GAPICs that support only one transport for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For PHP, this block generates a GAPIC that supports both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added comments to clarify, let me know if this is sufficient!

Copy link
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

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

Overall looks good. Just a few comments.
I'm also worried a bit about the addition of one more huge test file library_rest.proto. Why can't we use one of the existing library.proto. Is it because of streaming methods?

} else {
// PHP generates a client that only supports REST
apiImplClass.grpcClientTypeName("");
apiImplClass.stubs(new ArrayList<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: probably Collections.emptyList() is what you need here.

@@ -426,6 +437,9 @@ private RestPlaceholderConfigView generateRestPlaceholderConfigView(
List<GrpcStreamingDetailView> result = new ArrayList<>();

for (MethodModel method : context.getGrpcStreamingMethods()) {
if (!supportsGrpcTransport()) {
throw new RuntimeException("Streaming methods only valid for gRPC transport");
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this behave for existing APIs? There are many APIs that PHP generates the multitransport client and those have streaming methods. I believe in that case PHP still creates a client, just the streaming methods are no-op, but the generation itself does not fail and all the non-streaming methods are present in the generated surface. Will make gapic-generator throwing exception for such APIs and failing the whole generation process as a result?

Also, please do not use RuntimeException directly. It is an exception designed to be a base for the other specific exceptions. Please pick something more specific (UnsupportedOperation or something like that)

Copy link
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

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

LGTM

@bshaffer bshaffer merged commit 0456289 into master Dec 8, 2020
@bshaffer bshaffer deleted the add-rest-only-transport-option branch December 8, 2020 21:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants