-
Notifications
You must be signed in to change notification settings - Fork 438
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
Migrate to new protobuf implementation #512
Conversation
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 looking great, just a few early notes!
@@ -534,7 +544,7 @@ public function createSink($parent, $sink, $optionalArgs = []) | |||
/** | |||
* Updates a sink. If the named sink doesn't exist, then this method is | |||
* identical to | |||
* [sinks.create](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks/create). | |||
* [sinks.create](/logging/docs/api/reference/rest/v2/projects.sinks/create). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* Input document. | ||
* </pre> | ||
* | ||
* <code>.google.cloud.language.v1beta2.Document document = 1;</code> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/google-cloud-php.iml
Outdated
@@ -0,0 +1,9 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There are some types that still live in proto-client-php, for example: https://github.com/googleapis/proto-client-php/tree/proto3/src/Google/Logging/Type Should these be a part of this PR as well? |
src/Core/Serializer.php
Outdated
} | ||
$v = $arr; | ||
} | ||
elseif ($field->isRepeated()) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
If we do keep the protos in this repository, what do you think of the following? Instead of We Use A major downside here, is that the protos will live right next to the GAPIC clients - making it hard to distinguish which to use if looking directly at the source. An option then would be to use On the plus side, we stick to our core namespace of |
@dwsupplee That seems possible, but one problem is that the proto types do not all use the Google\Cloud namespace (e.g. the logging types are under |
That sounds like a great solution to me |
Given that, I think it might be best if we make the migration to the new protobuf implementation without including the generated types in google-cloud-php, and instead leaving them in proto-client-php. Then once we have that protobuf feature available, we can change the namespaces and move the generated classes. This has the downside of involving two disruptive changes, but the upside of not blocking on having that protobuf feature available. WDYT? |
Is it correct then that for packages we are currently GA on we would end up bumping them to 3.0 in a relatively short time frame? I have some definite reservations there - do you have an idea as to when it may be possible to get the update to change the namespaces? |
No, we should not be bumping them beyond 1.0. The affected GA API is Logging, but in that case we have gone GA on the manual layer but not on the GAPIC client or protobuf types, because we knew that these breaking changes would be required (and we documented that the GAPIC layer is still experimental). |
An update after some discussions with @bshaffer, @tmatsuo and @TeBoring: We are now looking to implement the proto option to set the PHP namespace (issue filed here: protocolbuffers/protobuf#3122) before we make the migration over to the new protobuf implementation. This will allow us to move all of the generated protobuf types into the There is also a new issue in protobuf that I discovered today while running Spanner integration tests, which we will need to resolve before we can complete the migration: protocolbuffers/protobuf#3139 |
I have updated the PR to include:
This PR is awful to review because of the proto files. Since it is not passing test yet anyway, WDYT if I remove the proto types for now? |
After much struggling with HHVM, I have come up against a tricky problem. The reason it is failing is this code in protobuf. This is problematic because (1) this code is a PARSE-time error in HHVM, not a runtime error, and (2) this code does NOT follow PSR-4, meaning it is not autoloaded, but always loaded. Therefore, just skipping the gRPC tests is not sufficient - it is necessary to conditionally remove the dependencies on google/protobuf, google/gax and google/proto-client-php for HHVM. After doing that, we then hit the problem on the snippet parser, which also tries to load all the classes and errors when it can't. I think this can be solved by adding an exclude list for the snippet parser, which checks for HHVM and conditionally does not check the Spanner files for snippets. This would also allow use to remove the stanley-cheung/protobuf-php dependency. |
That sounds like a solid solution for now, and hopefully we can get HHVM support sooner rather than later. |
HHVM tests are now passing. I did not need to use an exclusion list for grpc snippets in the end, but having implemented it, I have retained it to remove the I believe this is ready for final review, pending releases of GAX and proto-client-php, and updating their docs to link externally instead of to code. |
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.
Very nice work. 👍
Just a few comments, overall LGTM!
composer.json
Outdated
"google/gax": "^0.10", | ||
"google/proto-client": "^0.20.0", | ||
"google/gax": "^0.20.0", | ||
"google/protobuf": "3.3.2", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"symfony/lock": "3.3.x-dev#1ba6ac9" | ||
}, | ||
"suggest": { | ||
"google/gax": "Required to support gRPC", | ||
"google/proto-client-php": "Required to support gRPC", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -17,8 +17,14 @@ | |||
|
|||
namespace Google\Cloud\Dev\Snippet\Coverage; | |||
|
|||
use Google\Cloud\Dev\CheckGrpcTrait; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/external-classes.json
Outdated
}, { | ||
"name": "Google\\GAX\\", | ||
"uri": "https://github.com/googleapis/gax-php/tree/master/src/%s.php" | ||
"uri": "https://googleapis.github.io/gax-php/master/Google/GAX/%s.html" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/Spanner/composer.json
Outdated
"google/cloud-core": "^1.4", | ||
"google/gax": "^0.10", | ||
"google/proto-client-php": "^0.13" | ||
"google/cloud-core": "^1.6", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
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.
Did we need to revert the snippet changes (9c4b04b) (a518c92)?
We didn't need to, but because we aren't including the protobuf classes, there wasn't a reason to change them, and I wanted to minimize the changes in this PR. If you think they are a worthwhile change in their own right (or just worth adding as preparation) and can add them back in.
composer.json
Outdated
"google/gax": "^0.10", | ||
"google/proto-client": "^0.20.0", | ||
"google/gax": "^0.20.0", | ||
"google/protobuf": "3.3.2", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
"symfony/lock": "3.3.x-dev#1ba6ac9" | ||
}, | ||
"suggest": { | ||
"google/gax": "Required to support gRPC", | ||
"google/proto-client-php": "Required to support gRPC", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -17,8 +17,14 @@ | |||
|
|||
namespace Google\Cloud\Dev\Snippet\Coverage; | |||
|
|||
use Google\Cloud\Dev\CheckGrpcTrait; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/external-classes.json
Outdated
}, { | ||
"name": "Google\\GAX\\", | ||
"uri": "https://github.com/googleapis/gax-php/tree/master/src/%s.php" | ||
"uri": "https://googleapis.github.io/gax-php/master/Google/GAX/%s.html" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/Spanner/composer.json
Outdated
"google/cloud-core": "^1.4", | ||
"google/gax": "^0.10", | ||
"google/proto-client-php": "^0.13" | ||
"google/cloud-core": "^1.6", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I wasn't sure if lines like this may cause issues, but after taking a quick look at the docs it appears we should be okay. Given that, I'm happy to keep the changes in this PR minimal, that works for me! |
Great! I believe I have addressed all changes, so this should be ready to merge - PTAL |
This PR still needs some cleaning up, but I wanted to start getting review sooner rather than later. Some points:
PhpArray
codec is replaced by aSerializer
object.