Skip to content
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

refactor: move module source to root #99

Merged
merged 13 commits into from
Jul 19, 2021
Merged
Next Next commit
refactor: move module source to root
  • Loading branch information
JustinBeckwith committed Jul 8, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 8c9466456d0daba0c306f26a1b937774ca091c12
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -16,9 +16,7 @@ jobs:
node-version: ${{ matrix.node }}
- run: node --version
- run: npm install
working-directory: ./grpc-gcp
- run: npm test
working-directory: ./grpc-gcp
windows:
runs-on: windows-latest
steps:
@@ -27,9 +25,7 @@ jobs:
with:
node-version: 14
- run: npm install
working-directory: ./grpc-gcp
- run: npm test
working-directory: ./grpc-gcp
lint:
runs-on: ubuntu-latest
steps:
@@ -38,6 +34,4 @@ jobs:
with:
node-version: 10
- run: npm install
working-directory: ./grpc-gcp
- run: npm run lint
working-directory: ./grpc-gcp
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -8,5 +8,5 @@ npm-debug.log
coverage

# generated code
grpc-gcp/test/google
test/google
cloudprober/google
File renamed without changes.
File renamed without changes.
File renamed without changes.
115 changes: 109 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,113 @@
# gRPC for GCP extensions
# gRPC-GCP for Node.js

Copyright 2018
[The gRPC Authors](https://github.com/grpc/grpc/blob/master/AUTHORS)
A Node.js module providing grpc supports for Google Cloud APIs.

## About This Repository
## Installation

This repo is created to support GCP specific extensions for gRPC. To use the extension features, please refer to [grpc-gcp](grpc-gcp).
```sh
npm install grpc-gcp --save
```

This repo also contains supporting infrastructures such as end2end tests and benchmarks for accessing cloud APIs with gRPC client libraries.
## Usage

Let's use Spanner API as an example.

First, Create a json file defining API configuration, with ChannelPoolConfig and MethodConfig.

```json
{
"channelPool": {
"maxSize": 10,
"maxConcurrentStreamsLowWatermark": 1
},
"method": [
{
"name": [ "/google.spanner.v1.Spanner/CreateSession" ],
"affinity": {
"command": "BIND",
"affinityKey": "name"
}
},
{
"name": [ "/google.spanner.v1.Spanner/GetSession" ],
"affinity": {
"command": "BOUND",
"affinityKey": "name"
}
},
{
"name": [ "/google.spanner.v1.Spanner/DeleteSession" ],
"affinity": {
"command": "UNBIND",
"affinityKey": "name"
}
}
]
}
```

Load configuration to ApiConfig.

```javascript
// @grpc/grpc-js can be used in place of grpc with no changes
var grpc = require('grpc');
var grpcGcp = require('grpc-gcp')(grpc);
var fs = require('fs');

var apiDefinition = JSON.parse(fs.readFileSync('your_api_config_json_file'));
var apiConfig = grpcGcp.createGcpApiConfig(apiDefinition);
```

Pass `gcpChannelFactoryOverride` and `gcpCallInvocationTransformer` to channel options when initializing api client.

```javascript
var channelOptions = {
channelFactoryOverride: grpcGcp.gcpChannelFactoryOverride,
callInvocationTransformer: grpcGcp.gcpCallInvocationTransformer,
gcpApiConfig: apiConfig,
};

var client = new SpannerClient(
'spanner.googleapis.com:443',
channelCreds,
channelOptions
);
```

## Build from source

Download source.

```sh
git clone https://github.com/GoogleCloudPlatform/grpc-gcp-node.git && cd grpc-gcp-node
```

```sh
git submodule update --init --recursive
```

Build grpc-gcp.

```sh
npm install
```

## Test

Setup credentials. See [Getting Started With Authentication](https://cloud.google.com/docs/authentication/getting-started) for more details.

```sh
export GOOGLE_APPLICATION_CREDENTIALS=path/to/key.json
```

Run unit tests.

```sh
npm test
```

Run system tests.

```sh
npm run system-test
```
File renamed without changes.
117 changes: 0 additions & 117 deletions grpc-gcp/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion grpc-gcp/package.json → package.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"build": "tsc && cp -r src/generated build/src/",
"system-test": "c8 mocha test/integration/*.js --reporter spec --timeout 10000",
"test": "c8 mocha test/unit/*.js --reporter spec",
"lint": "gts check",
"lint": "gts check src/**/*.ts",
"fix": "gts fix",
"prepare": "npm run build"
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.