-
Notifications
You must be signed in to change notification settings - Fork 451
Introduce Google Cloud Spanner #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
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.
couple odds and ends. still need to take more time studying the pool implementation.
src/Core/PhpArray.php
Outdated
| * } | ||
| */ | ||
| public function __construct(array $customFilters = []) | ||
| public function __construct(array $config = []) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/Logging/Connection/Grpc.php
Outdated
| 'outputVersionFormat' => function ($v) { | ||
| return self::$versionFormatMap[$v]; | ||
| } | ||
| 'customFilters' => [ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| $this->codec = new PhpArray(['publishTime' => function ($v) { | ||
| return $this->formatTimestampFromApi($v); | ||
| }]); | ||
| $this->codec = new PhpArray([ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/Spanner/Connection/Grpc.php
Outdated
| public function __construct(array $config = []) | ||
| { | ||
| $this->codec = new PhpArray([ | ||
| 'customFilters' => [ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Thanks for sending this. Really excited to see this!! |
|
@dwsupplee Thanks! |
| * @var array | ||
| */ | ||
| private static $defaultConfig = [ | ||
| 'maxSessions' => PHP_INT_MAX, |
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.
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.
| { | ||
| $sessions = []; | ||
|
|
||
| for ($i = 0; $i < $count; $i++) { |
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.
vkedia
left a comment
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.
Made some headway into the review.
| @@ -0,0 +1,44 @@ | |||
| { | |||
| "title": "Spanner", | |||
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.
| return false; | ||
| }); | ||
|
|
||
| $delay = $metadata[0]['retryDelay']; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| }); | ||
|
|
||
| $delay = $metadata[0]['retryDelay']; | ||
| if (!isset($delay['seconds'])) { |
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.
| * @param array $options [optional] Configuration options. | ||
| * @return mixed|null | ||
| */ | ||
| public function result(array $options = []) |
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/Configuration.php
Outdated
| * @see https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#instanceconfig InstanceConfig | ||
| * @codingStandardsIgnoreEnd | ||
| */ | ||
| class Configuration |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/Spanner/Database.php
Outdated
| } | ||
|
|
||
| /** | ||
| * Create and return a new read/write Transaction. |
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.
| * @param array $options [optional] Configuration options. | ||
| * @return Timestamp The commit Timestamp. | ||
| */ | ||
| public function insertBatch($table, array $dataSet, array $options = []) |
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/Database.php
Outdated
| /** | ||
| * Update a row. | ||
| * | ||
| * Only data which you wish to update need be included. You must provide |
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.
| } finally { | ||
| $session->setExpiration(); | ||
| } | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } finally { | ||
| $session->setExpiration(); | ||
| } | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Also do you guys handle null values everywhere? So params can be null (in that case how do you infer the type of the param?). Column values can be null, arrays can contain null. |
|
@vkedia, I'm looking into that now. What is a column definition which would accept null values as array elements? Column definition: Insert data: $database->insert('tableName', [
'arrayField' => [1, 2, null]
]);Error: That error isn't surprising, but I can't think of how one would add a null array element. The documentation says it is possible. |
|
@jdpedrie I believe all arrays can contain null elements. Can you try removing "NOT NULL" from there? |
|
@vkedia that did the trick. sorry for the noise. |
|
@jdpedrie Actually I am surprised that specifying "NOT NULL" also makes the elements be non nullable. |
|
@vkedia is there anything else we need to touch on besides #438 (comment)? |
| 'maxSessions' => PHP_INT_MAX, | ||
| 'minSessions' => 1, | ||
| 'shouldWaitForSession' => true, | ||
| 'maxCyclesToWaitForSession' => 30, |
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.
| * @var array | ||
| */ | ||
| private static $defaultConfig = [ | ||
| 'maxSessions' => PHP_INT_MAX, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| { | ||
| $sessions = []; | ||
|
|
||
| for ($i = 0; $i < $count; $i++) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| { | ||
| foreach ($data['inUse'] as $key => $session) { | ||
| if ($session['lastActive'] + 1200 < $this->time()) { | ||
| unset($data['inUse'][$key]); |
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.
| $session = array_shift($data['queue']); | ||
|
|
||
| if ($session) { | ||
| if ($session['expiration'] - 60 < $this->time()) { |
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.
| */ | ||
| private function purgeOrphanedToCreateItems(array &$data) | ||
| { | ||
| foreach ($data['toCreate'] as $key => $timestamp) { |
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.
| * @param array $config [optional] { | ||
| * Configuration Options. | ||
| * | ||
| * @type int $maxSessions The maximum number of sessions to store in the |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| public function release(Session $session); | ||
|
|
||
| /** | ||
| * Clear the session pool. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
I have added a bunch of comments to the SessionPool. |
|
Thanks for all the notes @vkedia! It's greatly appreciated. |
Add system test coverage. Add more read system tests and fix KeyRange issues Spanner transaction system tests Add remaining p0 spanner system tests
doc fix address code review move symfony/lock from require to suggest
src/Spanner/composer.json
Outdated
| }, | ||
| "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.
vkedia
left a comment
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.
Couple of minor comments
| * on an interval that matches when you expect to see a decrease in traffic. | ||
| * This will help ensure you never run into issues where the Spanner backend is | ||
| * locked up after having met the maximum number of sessions assigned per node | ||
| * (The current maximum sessions per node is 10k). |
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.
|
|
||
| return [ | ||
| 'deleted' => count($toDelete) - count($failed), | ||
| 'failed' => $failed |
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.
| /** | ||
| * Insert a row. | ||
| * | ||
| * Mutations are committed in a single-use transaction. |
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.
Introducing.... Google Cloud Spanner support for PHP!
This PR is ready for review and feedback with a small caveat, there are a small handful of tests which need to be updated yet.
A few items worth noting for discussion:
/cc @vkedia @tmatsuo
https://github.com/dwsupplee/gcloud-php/tree/spanner/src/Spanner
TODO