mirror of https://github.com/grpc/grpc.git
commit
51f066c585
72 changed files with 3824 additions and 1088 deletions
@ -1,8 +1,7 @@ |
||||
{ |
||||
"name": "grpc/grpc-demo", |
||||
"description": "gRPC example for PHP", |
||||
"minimum-stability": "dev", |
||||
"require": { |
||||
"grpc/grpc": "v0.15.2" |
||||
"grpc/grpc": "v1.0.0" |
||||
} |
||||
} |
||||
|
@ -1,135 +0,0 @@ |
||||
<?php |
||||
/* |
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
class CallCredentials3Test extends PHPUnit_Framework_TestCase |
||||
{ |
||||
public function setUp() |
||||
{ |
||||
$this->credentials = Grpc\ChannelCredentials::createSsl( |
||||
file_get_contents(dirname(__FILE__).'/../data/ca.pem')); |
||||
$server_credentials = Grpc\ServerCredentials::createSsl( |
||||
null, |
||||
file_get_contents(dirname(__FILE__).'/../data/server1.key'), |
||||
file_get_contents(dirname(__FILE__).'/../data/server1.pem')); |
||||
$this->server = new Grpc\Server(); |
||||
$this->port = $this->server->addSecureHttp2Port('0.0.0.0:0', |
||||
$server_credentials); |
||||
$this->server->start(); |
||||
$this->host_override = 'foo.test.google.fr'; |
||||
$this->channel = new Grpc\Channel( |
||||
'localhost:'.$this->port, |
||||
[ |
||||
'grpc.ssl_target_name_override' => $this->host_override, |
||||
'grpc.default_authority' => $this->host_override, |
||||
'credentials' => $this->credentials, |
||||
] |
||||
); |
||||
} |
||||
|
||||
public function tearDown() |
||||
{ |
||||
unset($this->channel); |
||||
unset($this->server); |
||||
} |
||||
|
||||
public function callbackFunc($context) |
||||
{ |
||||
$this->assertTrue(is_string($context->service_url)); |
||||
$this->assertTrue(is_string($context->method_name)); |
||||
|
||||
return ['k1' => ['v1'], 'k2' => ['v2']]; |
||||
} |
||||
|
||||
public function testCreateFromPlugin() |
||||
{ |
||||
$deadline = Grpc\Timeval::infFuture(); |
||||
$status_text = 'xyz'; |
||||
$call = new Grpc\Call($this->channel, |
||||
'/abc/dummy_method', |
||||
$deadline, |
||||
$this->host_override); |
||||
|
||||
$call_credentials = Grpc\CallCredentials::createFromPlugin( |
||||
[$this, 'callbackFunc']); |
||||
$call->setCredentials($call_credentials); |
||||
|
||||
$event = $call->startBatch([ |
||||
Grpc\OP_SEND_INITIAL_METADATA => [], |
||||
Grpc\OP_SEND_CLOSE_FROM_CLIENT => true, |
||||
]); |
||||
|
||||
$this->assertTrue($event->send_metadata); |
||||
$this->assertTrue($event->send_close); |
||||
|
||||
$event = $this->server->requestCall(); |
||||
|
||||
$this->assertTrue(is_array($event->metadata)); |
||||
$metadata = $event->metadata; |
||||
$this->assertTrue(array_key_exists('k1', $metadata)); |
||||
$this->assertTrue(array_key_exists('k2', $metadata)); |
||||
$this->assertSame($metadata['k1'], ['v1']); |
||||
$this->assertSame($metadata['k2'], ['v2']); |
||||
|
||||
$this->assertSame('/abc/dummy_method', $event->method); |
||||
$server_call = $event->call; |
||||
|
||||
$event = $server_call->startBatch([ |
||||
Grpc\OP_SEND_INITIAL_METADATA => [], |
||||
Grpc\OP_SEND_STATUS_FROM_SERVER => [ |
||||
'metadata' => [], |
||||
'code' => Grpc\STATUS_OK, |
||||
'details' => $status_text, |
||||
], |
||||
Grpc\OP_RECV_CLOSE_ON_SERVER => true, |
||||
]); |
||||
|
||||
$this->assertTrue($event->send_metadata); |
||||
$this->assertTrue($event->send_status); |
||||
$this->assertFalse($event->cancelled); |
||||
|
||||
$event = $call->startBatch([ |
||||
Grpc\OP_RECV_INITIAL_METADATA => true, |
||||
Grpc\OP_RECV_STATUS_ON_CLIENT => true, |
||||
]); |
||||
|
||||
$this->assertSame([], $event->metadata); |
||||
$status = $event->status; |
||||
$this->assertSame([], $status->metadata); |
||||
$this->assertSame(Grpc\STATUS_OK, $status->code); |
||||
$this->assertSame($status_text, $status->details); |
||||
|
||||
unset($call); |
||||
unset($server_call); |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
Project Overview |
||||
================ |
||||
The project, titled 'GRPC Python compatibility support', involved |
||||
collaborating with the GRPC team to improve the library compatibility |
||||
for the GRPC Python library. |
||||
|
||||
Python is, originally, a specification for a programming language. This |
||||
specification has been implemented differently in different |
||||
implementations of the [language specification](https://docs.python.org/3/reference/). |
||||
|
||||
A small, and by no means exhaustive, list of some major python implementations |
||||
is: |
||||
|
||||
- [CPython](https://www.python.org/): The reference implementation |
||||
- [Jython](http://www.jython.org/): Python implemented in Java |
||||
- [Python for .NET](http://pythonnet.sourceforge.net/): CPython implementation that enables .NET library usage |
||||
- [IronPython](http://ironpython.net/): Python implemented in .NET |
||||
- [PyPy](http://pypy.org/): Python implemented completely in Python |
||||
- [Stackless](https://bitbucket.org/stackless-dev/stackless/wiki/Home): Replaces the dependency for the C call stack with it's own stack |
||||
|
||||
The development in this project revolved around |
||||
introducing changes to the codebase that enable support for latest |
||||
stable as well as development releases of the reference implementation |
||||
(CPython) of the Python programming language namely `Python 3.4`, |
||||
`Python 3.5`,and `Python 3.6` as well as the stable releases of the |
||||
PyPy implementation. Special changes were required to enable PyPy |
||||
support because PyPy has a non-deterministic garbage collector that does |
||||
not rely on reference counting unlike the CPython garbage collector. |
||||
|
||||
The changes to the codebase involved changes to the library code as well |
||||
as changes to the tests and scripts in the test infrastructure which |
||||
resulted in both the library as well as the testing infrastructure being |
||||
Python 3.x and PyPy compatible. |
||||
|
||||
The list of merged commits, as of 22.08.2016 23:59 CEST, is summarized |
||||
here for the perusal of those interested: |
||||
|
||||
- [Enable py35 and py36 testing](https://github.com/grpc/grpc/commit/c478214e475e103c5cdf477f0adc18bba2c03903) |
||||
- [Make testing toolchain python 3.x compliant](https://github.com/grpc/grpc/commit/0589e533cd65a2ca9e0e610cc1b284d016986572) |
||||
- [Add .idea folder to .gitignore](https://github.com/grpc/grpc/commit/365ef40947e22b5438a63f123679ae9a5474c47c) |
||||
- [Fix the ThreadPoolExecutor: max_workers can't be 0](https://github.com/grpc/grpc/commit/de84d566b8fad6808e5263a25a17fa231cb5713c) |
||||
- [Add PyPy to testing toolchain](https://github.com/grpc/grpc/commit/2135a1b557f8b992186d5317cb767ac4dbcdfe5c) |
||||
- [Switch init/shutdown: lib-wide -> per-object](https://github.com/grpc/grpc/commit/9eedb4ffd74aed8d246a07f8007960b2bc167f55) |
||||
- [Skip test run if running with pypy](https://github.com/grpc/grpc/commit/f0f58e68738abbc317f7f449c5104f7fbbff26bd) |
||||
|
||||
The list of unmerged pull requests is as follows: |
||||
|
||||
- [Add PyPy 5.3.1 to dockerfile and template](https://github.com/grpc/grpc/pull/7763) |
||||
- [remove skipIf from TypeSmokeTest (issue 7672)](https://github.com/grpc/grpc/pull/7831) |
||||
|
||||
The list of tasks that have pending unsubmitted pull requests is as follows: |
||||
|
||||
- Modify run_tests.py to enable testing of new languages without |
||||
affecting old branches. |
||||
|
||||
|
||||
Project Details |
||||
=============== |
||||
- Title: GRPC Python compatibility support |
||||
- Student: [Siddharth Shukla](https://github.com/thunderboltsid) |
||||
- Mentors: [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm) |
||||
- Duration: May 23 - August 23 |
||||
- Hat tip: [Ken Payson](https://github.com/kpayson64), [Jan Tattermusch](https://github.com/jtattermusch), [Nicolas Noble](https://github.com/nicolasnoble) |
||||
|
||||
|
@ -0,0 +1,23 @@ |
||||
%YAML 1.2 |
||||
--- | |
||||
{ |
||||
"name": "grpc/grpc", |
||||
"type": "library", |
||||
"description": "gRPC library for PHP", |
||||
"keywords": ["rpc"], |
||||
"homepage": "http://grpc.io", |
||||
"license": "BSD-3-Clause", |
||||
"version": "${settings.php_version.php_composer()}", |
||||
"require": { |
||||
"php": ">=5.5.0", |
||||
"stanley-cheung/protobuf-php": "v0.6" |
||||
}, |
||||
"require-dev": { |
||||
"google/auth": "v0.9" |
||||
}, |
||||
"autoload": { |
||||
"psr-4": { |
||||
"Grpc\\": "lib/Grpc/" |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue