Skip to content

Commit f62ea45

Browse files
authored
adds App Engine Standard samples for using gRPC with Monitoring and Spanner (GoogleCloudPlatform#480)
1 parent 005f8d8 commit f62ea45

File tree

10 files changed

+2816
-0
lines changed

10 files changed

+2816
-0
lines changed

appengine/standard/grpc/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# gRPC for App Engine (standard)
2+
3+
This app demonstrates how to run gRPC client libraries on App Engine Standard.
4+
5+
## Setup
6+
7+
- Install [`composer`](https://getcomposer.org)
8+
- Install dependencies by running:
9+
10+
```sh
11+
composer install
12+
```
13+
14+
- Install the [Google Cloud SDK](https://developers.google.com/cloud/sdk/).
15+
16+
## Deploy to App Engine
17+
18+
### Run Locally
19+
20+
These samples cannot be run locally with the Dev AppServer because gRPC has not
21+
been packaged with the Dev AppServer for PHP at this time.
22+
23+
### Deploy with gcloud
24+
25+
**The Cloud Monitoring sample**
26+
27+
The monitoring sample will work out of the box by doing the following:
28+
29+
30+
```
31+
gcloud config set project YOUR_PROJECT_ID
32+
gcloud app deploy
33+
gcloud app browse
34+
```
35+
36+
The last command will open `https://{YOUR_PROJECT_ID}.appspot.com/`
37+
in your browser. Browse to `/monitoring` to see the sample.
38+
39+
**The Cloud Spanner sample**
40+
41+
You will need to create a [Spanner Instance][create_instance] and a
42+
[Spanner Database][create_database].
43+
44+
Next, open up `spanner.php` in a text editor and change the values of
45+
`your-instance-id` and `your-database-id` to the Instance ID and Database ID you
46+
created.
47+
48+
Now you can deploy your application and it will work as expected:
49+
50+
```
51+
gcloud config set project YOUR_PROJECT_ID
52+
gcloud app deploy
53+
gcloud app browse
54+
```
55+
56+
The last command will open `https://{YOUR_PROJECT_ID}.appspot.com/`
57+
in your browser. Browse to `/spanner` to see the sample.
58+
59+
[create_database]: https://cloud.google.com/spanner/docs/quickstart-console#create_a_database
60+
[create_instance]: https://cloud.google.com/spanner/docs/quickstart-console#create_an_instance

appengine/standard/grpc/app.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtime: php55
2+
api_version: 1
3+
4+
handlers:
5+
- url: /monitoring
6+
script: monitoring.php
7+
- url: /spanner
8+
script: spanner.php
9+
- url: /.*
10+
script: index.html

appengine/standard/grpc/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require": {
3+
"google/cloud-spanner": "^0.8.0",
4+
"google/cloud-monitoring": "^0.6.0"
5+
},
6+
"require-dev": {
7+
"google/cloud-tools": "^0.6.7",
8+
"phpunit/phpunit": "~4"
9+
}
10+
}

0 commit comments

Comments
 (0)