김수민

audio

Showing 1000 changed files with 4493 additions and 6 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

client_id = '_Z9uOc1SUzIz2Yb_n4dS'
client_secret = 'yLXuXOY5AH'
channelAccessToken= 'fc9C6uXxCpz92Oh9potEB4QR9cywO1Bbijego0VAgIrrpR/TfB2b+Mmy5M0xm6jyG7E8CNBIwDapxpGbICI89xuRREAq7qdetuRdtaqcYGz37RJ03vdbV2NXKIVSrWzmzlanzIDYBwEddWqTlamDNAdB04t89/1O/w1cDnyilFU='
channelSecret= 'dd8943fe60cb7bf15beafa7e1acf8c71'
accesskeyid='AKIAV6255WSP76ANIN5Z'
secretaccesskey=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
\ No newline at end of file
.env
\ No newline at end of file
.env PanguinKeyPair.pem
\ No newline at end of file
......
......@@ -2,8 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="5c08ae96-2f87-46c1-b81d-f30e494ce252" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/QR코드.JPG" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
</list>
......@@ -34,6 +35,16 @@
</list>
</option>
</component>
<component name="RunManager">
<configuration name="app.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="app.js" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Node.js.app.js" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
......@@ -45,7 +56,8 @@
<option name="presentableId" value="Default" />
<updated>1573898555947</updated>
<workItem from="1573898557106" duration="89000" />
<workItem from="1573899005304" duration="287000" />
<workItem from="1573899005304" duration="7410000" />
<workItem from="1574071758382" duration="6285000" />
</task>
<servers />
</component>
......
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA4gTDXs654qJjK3LaYBEWye+r3alooch1TbulavMkmAmgAaYtoOpUt0KqiASo
aLHHiG3n2Jhr2MQ0SynqVV+Yw4odmg57UwdbdFKhahykO9B+HVpRF3h4dkzVFJSGeJb7eNFeCufs
d2cDGwIS8zXxavFGpF56WoWF/9kcRaWF9nnaGE12tnnrLKd44kB0PxcDOpkNz3Ht6RG56mB8oeOs
Aq21t7z09oNrkngyYCBKak8jEGY1Ybx1iHjouW4EoqxD272PqFmgDFxbZQZxV/d3AtzxkdRXBspa
20mt/kM+OgdgsMt2gcbBJNysenEC2ewOvGXTDK+10z5hwpYf53O+KQIDAQABAoIBAGcuo36Bw8za
M4nfWiBnTM8Nspl0QIczO5IsKz1jGP6rzjdShRwkPl6XecC016lMF/qJqkFwfDOuhu0VipxFEzmZ
sR/mophqEG9PVc9amgOQkDKYS9L6NYxUUSafE7CzxMQIWPWDoal1Bq7qyHnt03PuCED7vMHcmSsP
E+Aby8eUR2rs/0Rhso2PViPjowhIV3dCLZ2EMcopbm2sRZBxbRLC/uPqkQhVE/thbZS2t0WZz46h
WkQ8ZUrpvKPAeRFouXUqRi1wi78Quwcoe5CwwnKNMDKKhWOn+JV1in1o8mVl2SuLUQ1j0HeC7nGy
McQG9NjJht0ywJw1n5i7Vk9bEn0CgYEA/l5LFJ0/YSoMlF/DEZN1pSNUenCscr++4XxQz2KrRayR
6tclv/c8R37qabmN+qtvxtCOc38jNs+XFkJlnN74oEc2yDk2pwmprRhaZo4bmTal79gCTbBOeirc
NcRoHB9BdfKlbqLHXRrBEKeJ97fymbPIakPvOc7BsIPBvxcmJvsCgYEA43fqdS9JlyaRlfWv3nuV
L3HS3JlKXlTs4cOcbZbqUV8ZzUPrHKNLlmuwr5IPKJjhl5wzpVPJOZgguWy2ep+04XyoBJKC44Ul
MwuE2yURU2ls5bbjVGKC25GZA4ZzEB2yg8EP6EHv0+3gcyq2NTyuc9i0RmyETNRAoLp83wPi9isC
gYAmXdibQmCV6j69fngwxXogL2UFlssb/7ntzs9tiGdm+fGEZ3ElNEheTFFVIwy8O3F/nmNuHkYU
dVlHnTowYB1GJ5emuaJ5rWZvWlYAU/zrrid3NrCaQTaFDMPsRDSj0T8RaEj1mA3UCD4IogyYVaF8
93YKOTbzFDF4y1bE2NwDUwKBgCJwCz0GlbueiTgM5D1otGNkdioTwyCY9uwPM2WcDYmYPk3HVJcX
WeBCGZPbJxRcYPsVGPSUxMhFcd7gyJe0CiyBNObMT6imhcU+nzSWXhMkyOnWUIB8EZewaVwRROZR
uK8d0Yy2Ptr1DqAg/Uj+EONVEaX/09/V2pr64ODas8fVAoGBALS/UNW0253H8FP7R+IdvhPSj/Y2
tu1PXv++UEqNAgblvc31Z8lrCeIyVMbH/2t2PenkN4GDvnTqx3z+PjP6+HgcgrBVOXMpCv/E3k2w
1+Ck8uMi41GfV+Ve7UmxMA/vnPO8Z52c01zHO9j+PGy3xhfxg1IDDjB6n7CiiAryMreC
-----END RSA PRIVATE KEY-----
\ No newline at end of file
//aws polly tts
const AWS = require('aws-sdk');
const fs=require('fs');
const { LineClient } = require('messaging-api-line');
require("dotenv").config({path : '.env'});
var express = require('express');
var app = express();
const line = require('@line/bot-sdk');
//papago api
var request = require('request');
......@@ -12,7 +15,14 @@ var request = require('request');
var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt';
//언어감지 api_url
var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs'
var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs';
//polly
const Polly =new AWS.Polly({
signatureVersion: 'v4',
region: 'ap-northeast-2',
accessKeyId:process.env.accesskeyid,
secretAccessKey:process.env.secretaccesskey
});
// Naver Auth Key
//새로 발급받은 naver papago api id, pw 입력
......@@ -26,7 +36,10 @@ const config = {
// create LINE SDK client
const client = new line.Client(config);
const for_audio_client=LineClient.connect({
channelAccessToken: process.env.channelAccessToken,
channelSecret: process.env.channelSecret,
});
// create Express app
// about Express itself: https://expressjs.com/
......@@ -93,6 +106,7 @@ function handleEvent(event) {
console.log(result.text);
//번역된 문장 보내기
client.replyMessage(event.replyToken,result).then(resolve).catch(reject);
}
});
}
......
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../google-gax/build/tools/compileProtos.js" "$@"
ret=$?
else
node "$basedir/../google-gax/build/tools/compileProtos.js" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\google-gax\build\tools\compileProtos.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\google-gax\build\tools\compileProtos.js" %*
)
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../google-p12-pem/build/src/bin/gp12-pem.js" "$@"
ret=$?
else
node "$basedir/../google-p12-pem/build/src/bin/gp12-pem.js" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\google-p12-pem\build\src\bin\gp12-pem.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\google-p12-pem\build\src\bin\gp12-pem.js" %*
)
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../protobufjs/bin/pbjs" "$@"
ret=$?
else
node "$basedir/../protobufjs/bin/pbjs" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\protobufjs\bin\pbjs" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\protobufjs\bin\pbjs" %*
)
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../protobufjs/bin/pbts" "$@"
ret=$?
else
node "$basedir/../protobufjs/bin/pbts" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\protobufjs\bin\pbts" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\protobufjs\bin\pbts" %*
)
\ No newline at end of file
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
ret=$?
else
node "$basedir/../semver/bin/semver.js" "$@"
ret=$?
fi
exit $ret
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\semver\bin\semver.js" %*
)
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
[//]: # "This README.md file is auto-generated, all changes to this file will be lost."
[//]: # "To regenerate it, use `python -m synthtool`."
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
# [Google Cloud Text-to-Speech: Node.js Client](https://github.com/googleapis/nodejs-text-to-speech)
[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/@google-cloud/text-to-speech.svg)](https://www.npmjs.org/package/@google-cloud/text-to-speech)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-text-to-speech/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-text-to-speech)
Cloud Text-to-Speech API client for Node.js
* [Google Cloud Text-to-Speech Node.js Client API Reference][client-docs]
* [Google Cloud Text-to-Speech Documentation][product-docs]
* [github.com/googleapis/nodejs-text-to-speech](https://github.com/googleapis/nodejs-text-to-speech)
Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
**Table of contents:**
* [Quickstart](#quickstart)
* [Before you begin](#before-you-begin)
* [Installing the client library](#installing-the-client-library)
* [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Versioning](#versioning)
* [Contributing](#contributing)
* [License](#license)
## Quickstart
### Before you begin
1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the Google Cloud Text-to-Speech API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.
### Installing the client library
```bash
npm install @google-cloud/text-to-speech
```
### Using the client library
```javascript
// Imports the Google Cloud client library
const textToSpeech = require('@google-cloud/text-to-speech');
// Import other required libraries
const fs = require('fs');
const util = require('util');
async function main() {
// Creates a client
const client = new textToSpeech.TextToSpeechClient();
// The text to synthesize
const text = 'Hello, world!';
// Construct the request
const request = {
input: {text: text},
// Select the language and SSML Voice Gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// Select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};
// Performs the Text-to-Speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
const writeFile = util.promisify(fs.writeFile);
await writeFile('output.mp3', response.audioContent, 'binary');
console.log('Audio content written to file: output.mp3');
}
```
## Samples
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-text-to-speech/tree/master/samples) directory. The samples' `README.md`
has instructions for running the samples.
| Sample | Source Code | Try it |
| --------------------------- | --------------------------------- | ------ |
| Audio Profile | [source code](https://github.com/googleapis/nodejs-text-to-speech/blob/master/samples/audioProfile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-text-to-speech&page=editor&open_in_editor=samples/audioProfile.js,samples/README.md) |
| List Voices | [source code](https://github.com/googleapis/nodejs-text-to-speech/blob/master/samples/listVoices.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-text-to-speech&page=editor&open_in_editor=samples/listVoices.js,samples/README.md) |
| Quickstart | [source code](https://github.com/googleapis/nodejs-text-to-speech/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-text-to-speech&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
| Ssml Addresses | [source code](https://github.com/googleapis/nodejs-text-to-speech/blob/master/samples/ssmlAddresses.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-text-to-speech&page=editor&open_in_editor=samples/ssmlAddresses.js,samples/README.md) |
| Synthesize | [source code](https://github.com/googleapis/nodejs-text-to-speech/blob/master/samples/synthesize.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-text-to-speech&page=editor&open_in_editor=samples/synthesize.js,samples/README.md) |
The [Google Cloud Text-to-Speech Node.js Client API Reference][client-docs] documentation
also contains samples.
## Versioning
This library follows [Semantic Versioning](http://semver.org/).
This library is considered to be in **alpha**. This means it is still a
work-in-progress and under active development. Any release is subject to
backwards-incompatible changes at any time.
More Information: [Google Cloud Platform Launch Stages][launch_stages]
[launch_stages]: https://cloud.google.com/terms/launch-stages
## Contributing
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-text-to-speech/blob/master/CONTRIBUTING.md).
## License
Apache Version 2.0
See [LICENSE](https://github.com/googleapis/nodejs-text-to-speech/blob/master/LICENSE)
[client-docs]: https://googleapis.dev/nodejs/text-to-speech/latest
[product-docs]: https://cloud.google.com/text-to-speech
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=texttospeech.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
import * as v1beta1 from './v1beta1';
import * as v1 from './v1';
declare const TextToSpeechClient: typeof v1.TextToSpeechClient;
export { v1, v1beta1, TextToSpeechClient };
declare const _default: {
v1: typeof v1;
v1beta1: typeof v1beta1;
TextToSpeechClient: typeof v1.TextToSpeechClient;
};
export default _default;
"use strict";
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
Object.defineProperty(exports, "__esModule", { value: true });
const v1beta1 = require("./v1beta1");
exports.v1beta1 = v1beta1;
const v1 = require("./v1");
exports.v1 = v1;
const TextToSpeechClient = v1.TextToSpeechClient;
exports.TextToSpeechClient = TextToSpeechClient;
// For compatibility with JavaScript libraries we need to provide this default export:
// tslint:disable-next-line no-default-export
exports.default = { v1, v1beta1, TextToSpeechClient };
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,qDAAqD;;AAErD,qCAAqC;AAIzB,0BAAO;AAHnB,2BAA2B;AAGnB,gBAAE;AADV,MAAM,kBAAkB,GAAG,EAAE,CAAC,kBAAkB,CAAC;AAC5B,gDAAkB;AACvC,sFAAsF;AACtF,6CAA6C;AAC7C,kBAAe,EAAC,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAC,CAAC"}
\ No newline at end of file
export { TextToSpeechClient } from './text_to_speech_client';
"use strict";
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
Object.defineProperty(exports, "__esModule", { value: true });
var text_to_speech_client_1 = require("./text_to_speech_client");
exports.TextToSpeechClient = text_to_speech_client_1.TextToSpeechClient;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v1/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,qDAAqD;;AAErD,iEAA2D;AAAnD,qDAAA,kBAAkB,CAAA"}
\ No newline at end of file
import * as gax from 'google-gax';
import { Callback, ClientOptions } from 'google-gax';
import * as protosTypes from '../../protos/protos';
/**
* Service that implements Google Cloud Text-to-Speech API.
* @class
* @memberof v1
*/
export declare class TextToSpeechClient {
private _descriptors;
private _textToSpeechStub;
private _innerApiCalls;
private _terminated;
auth: gax.GoogleAuth;
/**
* Construct an instance of TextToSpeechClient.
*
* @param {object} [options] - The configuration object. See the subsequent
* parameters for more details.
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts?: ClientOptions);
/**
* The DNS address for this API service.
*/
static get servicePath(): string;
/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint(): string;
/**
* The port for this API service.
*/
static get port(): number;
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
*/
static get scopes(): string[];
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
listVoices(request: protosTypes.google.cloud.texttospeech.v1.IListVoicesRequest, options?: gax.CallOptions): Promise<[protosTypes.google.cloud.texttospeech.v1.IListVoicesResponse, protosTypes.google.cloud.texttospeech.v1.IListVoicesRequest | undefined, {} | undefined]>;
listVoices(request: protosTypes.google.cloud.texttospeech.v1.IListVoicesRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.cloud.texttospeech.v1.IListVoicesResponse, protosTypes.google.cloud.texttospeech.v1.IListVoicesRequest | undefined, {} | undefined>): void;
synthesizeSpeech(request: protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest, options?: gax.CallOptions): Promise<[protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, (protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest | undefined), {} | undefined]>;
synthesizeSpeech(request: protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, protosTypes.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest | undefined, {} | undefined>): void;
/**
* Terminate the GRPC channel and close the client.
*
* The client will no longer be usable and all future behavior is undefined.
*/
close(): Promise<void>;
}
{"version":3,"file":"text_to_speech_client.js","sourceRoot":"","sources":["../../../src/v1/text_to_speech_client.ts"],"names":[],"mappings":"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"}
\ No newline at end of file
export declare const interfaces: {
"google.cloud.texttospeech.v1.TextToSpeech": {
"retry_codes": {
"non_idempotent": never[];
"idempotent": string[];
};
"retry_params": {
"default": {
"initial_retry_delay_millis": number;
"retry_delay_multiplier": number;
"max_retry_delay_millis": number;
"initial_rpc_timeout_millis": number;
"rpc_timeout_multiplier": number;
"max_rpc_timeout_millis": number;
"total_timeout_millis": number;
};
};
"methods": {
"ListVoices": {
"timeout_millis": number;
"retry_codes_name": string;
"retry_params_name": string;
};
"SynthesizeSpeech": {
"timeout_millis": number;
"retry_codes_name": string;
"retry_params_name": string;
};
};
};
};
{
"interfaces": {
"google.cloud.texttospeech.v1.TextToSpeech": {
"retry_codes": {
"non_idempotent": [],
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
]
},
"retry_params": {
"default": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1,
"max_rpc_timeout_millis": 20000,
"total_timeout_millis": 600000
}
},
"methods": {
"ListVoices": {
"timeout_millis": 600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"SynthesizeSpeech": {
"timeout_millis": 600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
}
}
}
}
}
export { TextToSpeechClient } from './text_to_speech_client';
"use strict";
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
Object.defineProperty(exports, "__esModule", { value: true });
var text_to_speech_client_1 = require("./text_to_speech_client");
exports.TextToSpeechClient = text_to_speech_client_1.TextToSpeechClient;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v1beta1/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,qDAAqD;;AAErD,iEAA2D;AAAnD,qDAAA,kBAAkB,CAAA"}
\ No newline at end of file
import * as gax from 'google-gax';
import { Callback, ClientOptions } from 'google-gax';
import * as protosTypes from '../../protos/protos';
/**
* Service that implements Google Cloud Text-to-Speech API.
* @class
* @memberof v1beta1
*/
export declare class TextToSpeechClient {
private _descriptors;
private _textToSpeechStub;
private _innerApiCalls;
private _terminated;
auth: gax.GoogleAuth;
/**
* Construct an instance of TextToSpeechClient.
*
* @param {object} [options] - The configuration object. See the subsequent
* parameters for more details.
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {function} [options.promise] - Custom promise module to use instead
* of native Promises.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts?: ClientOptions);
/**
* The DNS address for this API service.
*/
static get servicePath(): string;
/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint(): string;
/**
* The port for this API service.
*/
static get port(): number;
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
*/
static get scopes(): string[];
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
listVoices(request: protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesRequest, options?: gax.CallOptions): Promise<[protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesResponse, (protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesRequest | undefined), {} | undefined]>;
listVoices(request: protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesResponse, protosTypes.google.cloud.texttospeech.v1beta1.IListVoicesRequest | undefined, {} | undefined>): void;
synthesizeSpeech(request: protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest, options?: gax.CallOptions): Promise<[protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, (protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | undefined), {} | undefined]>;
synthesizeSpeech(request: protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechResponse, protosTypes.google.cloud.texttospeech.v1beta1.ISynthesizeSpeechRequest | undefined, {} | undefined>): void;
/**
* Terminate the GRPC channel and close the client.
*
* The client will no longer be usable and all future behavior is undefined.
*/
close(): Promise<void>;
}
{"version":3,"file":"text_to_speech_client.js","sourceRoot":"","sources":["../../../src/v1beta1/text_to_speech_client.ts"],"names":[],"mappings":"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"}
\ No newline at end of file
export declare const interfaces: {
"google.cloud.texttospeech.v1beta1.TextToSpeech": {
"retry_codes": {
"non_idempotent": never[];
"idempotent": string[];
};
"retry_params": {
"default": {
"initial_retry_delay_millis": number;
"retry_delay_multiplier": number;
"max_retry_delay_millis": number;
"initial_rpc_timeout_millis": number;
"rpc_timeout_multiplier": number;
"max_rpc_timeout_millis": number;
"total_timeout_millis": number;
};
};
"methods": {
"ListVoices": {
"timeout_millis": number;
"retry_codes_name": string;
"retry_params_name": string;
};
"SynthesizeSpeech": {
"timeout_millis": number;
"retry_codes_name": string;
"retry_params_name": string;
};
};
};
};
{
"interfaces": {
"google.cloud.texttospeech.v1beta1.TextToSpeech": {
"retry_codes": {
"non_idempotent": [],
"idempotent": [
"DEADLINE_EXCEEDED",
"UNAVAILABLE"
]
},
"retry_params": {
"default": {
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1,
"max_rpc_timeout_millis": 20000,
"total_timeout_millis": 600000
}
},
"methods": {
"ListVoices": {
"timeout_millis": 600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
},
"SynthesizeSpeech": {
"timeout_millis": 600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default"
}
}
}
}
}
{
"_from": "@google-cloud/text-to-speech",
"_id": "@google-cloud/text-to-speech@2.0.0",
"_inBundle": false,
"_integrity": "sha512-bJ17PBL0XL88my64lYcC0uNaARxQ2Y4Jdu6aQVUELb9tgeaZg2PbLQFPoXi0tRm5tyF7cJMD0awKlKnNzI/D5g==",
"_location": "/@google-cloud/text-to-speech",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "@google-cloud/text-to-speech",
"name": "@google-cloud/text-to-speech",
"escapedName": "@google-cloud%2ftext-to-speech",
"scope": "@google-cloud",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/@google-cloud/text-to-speech/-/text-to-speech-2.0.0.tgz",
"_shasum": "1a5848298d6a16e5bb135bcab22a613a0f94fad7",
"_spec": "@google-cloud/text-to-speech",
"_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT",
"author": {
"name": "Google LLC"
},
"bugs": {
"url": "https://github.com/googleapis/nodejs-text-to-speech/issues"
},
"bundleDependencies": false,
"dependencies": {
"google-gax": "^1.9.0"
},
"deprecated": false,
"description": "Cloud Text-to-Speech API client for Node.js",
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/node": "^12.0.0",
"c8": "^6.0.0",
"codecov": "^3.0.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.0.0",
"gts": "^1.0.0",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"jsdoc-fresh": "^1.0.1",
"jsdoc-region-tag": "^1.0.2",
"linkinator": "^1.5.0",
"mocha": "^6.1.4",
"null-loader": "^3.0.0",
"pack-n-play": "^1.0.0-2",
"power-assert": "^1.4.4",
"prettier": "^1.11.1",
"ts-loader": "^6.2.1",
"typescript": "^3.7.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">=8.10.0"
},
"files": [
"build/protos",
"build/src"
],
"homepage": "https://github.com/googleapis/nodejs-text-to-speech#readme",
"keywords": [
"google apis client",
"google api client",
"google apis",
"google api",
"google",
"google cloud platform",
"google cloud",
"cloud",
"google texttospeech",
"texttospeech",
"Cloud Text-to-Speech API"
],
"license": "Apache-2.0",
"main": "build/src/index.js",
"name": "@google-cloud/text-to-speech",
"repository": {
"type": "git",
"url": "git+https://github.com/googleapis/nodejs-text-to-speech.git"
},
"scripts": {
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"docs-test": "linkinator docs",
"fix": "gts fix",
"lint": "gts fix && eslint --fix samples/*.js samples/**/*.js",
"predocs-test": "npm run docs",
"prepare": "npm run compile",
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
"system-test": "mocha build/system-test",
"test": "c8 mocha build/test"
},
"version": "2.0.0"
}
This diff is collapsed. Click to expand it.
# Pure JavaScript gRPC Client
**Note: This is an beta-level release. Some APIs may not yet be present and there may be bugs. Please report any that you encounter**
## Installation
Node 10 is recommended. The exact set of compatible Node versions can be found in the `engines` field of the `package.json` file.
```sh
npm install @grpc/grpc-js
```
## Features
- Unary and streaming calls
- Cancellation
- Deadlines
- TLS channel credentials
- Call credentials (for auth)
- Simple reconnection
- Channel API
This library does not directly handle `.proto` files. To use `.proto` files with this library we recommend using the `@grpc/proto-loader` package.
## Some Notes on API Guarantees
The public API of this library follows semantic versioning, with some caveats:
- Some methods are prefixed with an underscore. These methods are internal and should not be considered part of the public API.
- The class `Call` is only exposed due to limitations of TypeScript. It should not be considered part of the public API.
- In general, any API that is exposed by this library but is not exposed by the `grpc` library is likely an error and should not be considered part of the public API.
export interface BackoffOptions {
initialDelay?: number;
multiplier?: number;
jitter?: number;
maxDelay?: number;
}
export declare class BackoffTimeout {
private callback;
private initialDelay;
private multiplier;
private maxDelay;
private jitter;
private nextDelay;
private timerId;
private running;
constructor(callback: () => void, options?: BackoffOptions);
/**
* Call the callback after the current amount of delay time
*/
runOnce(): void;
/**
* Stop the timer. The callback will not be called until `runOnce` is called
* again.
*/
stop(): void;
/**
* Reset the delay time to its initial value.
*/
reset(): void;
isRunning(): boolean;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const INITIAL_BACKOFF_MS = 1000;
const BACKOFF_MULTIPLIER = 1.6;
const MAX_BACKOFF_MS = 120000;
const BACKOFF_JITTER = 0.2;
/**
* Get a number uniformly at random in the range [min, max)
* @param min
* @param max
*/
function uniformRandom(min, max) {
return Math.random() * (max - min) + min;
}
class BackoffTimeout {
constructor(callback, options) {
this.callback = callback;
this.initialDelay = INITIAL_BACKOFF_MS;
this.multiplier = BACKOFF_MULTIPLIER;
this.maxDelay = MAX_BACKOFF_MS;
this.jitter = BACKOFF_JITTER;
this.running = false;
if (options) {
if (options.initialDelay) {
this.initialDelay = options.initialDelay;
}
if (options.multiplier) {
this.multiplier = options.multiplier;
}
if (options.jitter) {
this.jitter = options.jitter;
}
if (options.maxDelay) {
this.maxDelay = options.maxDelay;
}
}
this.nextDelay = this.initialDelay;
this.timerId = setTimeout(() => { }, 0);
clearTimeout(this.timerId);
}
/**
* Call the callback after the current amount of delay time
*/
runOnce() {
this.running = true;
this.timerId = setTimeout(() => {
this.callback();
this.running = false;
}, this.nextDelay);
const nextBackoff = Math.min(this.nextDelay * this.multiplier, this.maxDelay);
const jitterMagnitude = nextBackoff * this.jitter;
this.nextDelay =
nextBackoff + uniformRandom(-jitterMagnitude, jitterMagnitude);
}
/**
* Stop the timer. The callback will not be called until `runOnce` is called
* again.
*/
stop() {
clearTimeout(this.timerId);
this.running = false;
}
/**
* Reset the delay time to its initial value.
*/
reset() {
this.nextDelay = this.initialDelay;
}
isRunning() {
return this.running;
}
}
exports.BackoffTimeout = BackoffTimeout;
//# sourceMappingURL=backoff-timeout.js.map
\ No newline at end of file
import { Call } from './call-stream';
import { Channel } from './channel';
import { BaseFilter, Filter, FilterFactory } from './filter';
import { Metadata } from './metadata';
export declare class CallCredentialsFilter extends BaseFilter implements Filter {
private readonly channel;
private readonly stream;
private serviceUrl;
constructor(channel: Channel, stream: Call);
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
}
export declare class CallCredentialsFilterFactory implements FilterFactory<CallCredentialsFilter> {
private readonly channel;
constructor(channel: Channel);
createFilter(callStream: Call): CallCredentialsFilter;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const filter_1 = require("./filter");
class CallCredentialsFilter extends filter_1.BaseFilter {
constructor(channel, stream) {
super();
this.channel = channel;
this.stream = stream;
this.channel = channel;
this.stream = stream;
const splitPath = stream.getMethod().split('/');
let serviceName = '';
/* The standard path format is "/{serviceName}/{methodName}", so if we split
* by '/', the first item should be empty and the second should be the
* service name */
if (splitPath.length >= 2) {
serviceName = splitPath[1];
}
/* Currently, call credentials are only allowed on HTTPS connections, so we
* can assume that the scheme is "https" */
this.serviceUrl = `https://${stream.getHost()}/${serviceName}`;
}
async sendMetadata(metadata) {
const credentials = this.stream.getCredentials();
const credsMetadata = credentials.generateMetadata({
service_url: this.serviceUrl,
});
const resultMetadata = await metadata;
resultMetadata.merge(await credsMetadata);
return resultMetadata;
}
}
exports.CallCredentialsFilter = CallCredentialsFilter;
class CallCredentialsFilterFactory {
constructor(channel) {
this.channel = channel;
this.channel = channel;
}
createFilter(callStream) {
return new CallCredentialsFilter(this.channel, callStream);
}
}
exports.CallCredentialsFilterFactory = CallCredentialsFilterFactory;
//# sourceMappingURL=call-credentials-filter.js.map
\ No newline at end of file
import { Metadata } from './metadata';
export interface CallMetadataOptions {
service_url: string;
}
export declare type CallMetadataGenerator = (options: CallMetadataOptions, cb: (err: Error | null, metadata?: Metadata) => void) => void;
/**
* A class that represents a generic method of adding authentication-related
* metadata on a per-request basis.
*/
export declare abstract class CallCredentials {
/**
* Asynchronously generates a new Metadata object.
* @param options Options used in generating the Metadata object.
*/
abstract generateMetadata(options: CallMetadataOptions): Promise<Metadata>;
/**
* Creates a new CallCredentials object from properties of both this and
* another CallCredentials object. This object's metadata generator will be
* called first.
* @param callCredentials The other CallCredentials object.
*/
abstract compose(callCredentials: CallCredentials): CallCredentials;
/**
* Check whether two call credentials objects are equal. Separate
* SingleCallCredentials with identical metadata generator functions are
* equal.
* @param other The other CallCredentials object to compare with.
*/
abstract _equals(other: CallCredentials): boolean;
/**
* Creates a new CallCredentials object from a given function that generates
* Metadata objects.
* @param metadataGenerator A function that accepts a set of options, and
* generates a Metadata object based on these options, which is passed back
* to the caller via a supplied (err, metadata) callback.
*/
static createFromMetadataGenerator(metadataGenerator: CallMetadataGenerator): CallCredentials;
static createEmpty(): CallCredentials;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const metadata_1 = require("./metadata");
/**
* A class that represents a generic method of adding authentication-related
* metadata on a per-request basis.
*/
class CallCredentials {
/**
* Creates a new CallCredentials object from a given function that generates
* Metadata objects.
* @param metadataGenerator A function that accepts a set of options, and
* generates a Metadata object based on these options, which is passed back
* to the caller via a supplied (err, metadata) callback.
*/
static createFromMetadataGenerator(metadataGenerator) {
return new SingleCallCredentials(metadataGenerator);
}
static createEmpty() {
return new EmptyCallCredentials();
}
}
exports.CallCredentials = CallCredentials;
class ComposedCallCredentials extends CallCredentials {
constructor(creds) {
super();
this.creds = creds;
}
async generateMetadata(options) {
const base = new metadata_1.Metadata();
const generated = await Promise.all(this.creds.map(cred => cred.generateMetadata(options)));
for (const gen of generated) {
base.merge(gen);
}
return base;
}
compose(other) {
return new ComposedCallCredentials(this.creds.concat([other]));
}
_equals(other) {
if (this === other) {
return true;
}
if (other instanceof ComposedCallCredentials) {
return this.creds.every((value, index) => value._equals(other.creds[index]));
}
else {
return false;
}
}
}
class SingleCallCredentials extends CallCredentials {
constructor(metadataGenerator) {
super();
this.metadataGenerator = metadataGenerator;
}
generateMetadata(options) {
return new Promise((resolve, reject) => {
this.metadataGenerator(options, (err, metadata) => {
if (metadata !== undefined) {
resolve(metadata);
}
else {
reject(err);
}
});
});
}
compose(other) {
return new ComposedCallCredentials([this, other]);
}
_equals(other) {
if (this === other) {
return true;
}
if (other instanceof SingleCallCredentials) {
return this.metadataGenerator === other.metadataGenerator;
}
else {
return false;
}
}
}
class EmptyCallCredentials extends CallCredentials {
generateMetadata(options) {
return Promise.resolve(new metadata_1.Metadata());
}
compose(other) {
return other;
}
_equals(other) {
return other instanceof EmptyCallCredentials;
}
}
//# sourceMappingURL=call-credentials.js.map
\ No newline at end of file
/// <reference types="node" />
import * as http2 from 'http2';
import { Duplex } from 'stream';
import { CallCredentials } from './call-credentials';
import { Status } from './constants';
import { EmitterAugmentation1 } from './events';
import { Filter } from './filter';
import { FilterStackFactory } from './filter-stack';
import { Metadata } from './metadata';
import { ObjectDuplex, WriteCallback } from './object-stream';
import { ChannelImplementation } from './channel';
import { Subchannel } from './subchannel';
export declare type Deadline = Date | number;
export interface CallStreamOptions {
deadline: Deadline;
flags: number;
host: string;
parentCall: Call | null;
}
export declare type PartialCallStreamOptions = Partial<CallStreamOptions>;
export interface StatusObject {
code: Status;
details: string;
metadata: Metadata;
}
export declare const enum WriteFlags {
BufferHint = 1,
NoCompress = 2,
WriteThrough = 4
}
export interface WriteObject {
message: Buffer;
flags?: number;
}
/**
* This interface represents a duplex stream associated with a single gRPC call.
*/
export declare type Call = {
cancelWithStatus(status: Status, details: string): void;
getPeer(): string;
sendMetadata(metadata: Metadata): void;
getDeadline(): Deadline;
getCredentials(): CallCredentials;
setCredentials(credentials: CallCredentials): void;
getStatus(): StatusObject | null;
getMethod(): string;
getHost(): string;
} & EmitterAugmentation1<'metadata', Metadata> & EmitterAugmentation1<'status', StatusObject> & ObjectDuplex<WriteObject, Buffer>;
export declare class Http2CallStream extends Duplex implements Call {
private readonly methodName;
private readonly channel;
private readonly options;
private readonly channelCallCredentials;
credentials: CallCredentials;
filterStack: Filter;
private http2Stream;
private pendingRead;
private pendingWrite;
private pendingWriteCallback;
private pendingFinalCallback;
private decoder;
private isReadFilterPending;
private canPush;
private unpushedReadMessages;
private unfilteredReadMessages;
private mappedStatusCode;
private handlingHeaders;
private handlingTrailers;
private finalStatus;
private subchannel;
private disconnectListener;
constructor(methodName: string, channel: ChannelImplementation, options: CallStreamOptions, filterStackFactory: FilterStackFactory, channelCallCredentials: CallCredentials);
/**
* On first call, emits a 'status' event with the given StatusObject.
* Subsequent calls are no-ops.
* @param status The status of the call.
*/
private endCall;
private handleFilterError;
private handleFilteredRead;
private filterReceivedMessage;
private tryPush;
private handleTrailers;
attachHttp2Stream(stream: http2.ClientHttp2Stream, subchannel: Subchannel): void;
sendMetadata(metadata: Metadata): void;
private destroyHttp2Stream;
cancelWithStatus(status: Status, details: string): void;
getDeadline(): Deadline;
getCredentials(): CallCredentials;
setCredentials(credentials: CallCredentials): void;
getStatus(): StatusObject | null;
getPeer(): string;
getMethod(): string;
getHost(): string;
_read(size: number): void;
_write(chunk: WriteObject, encoding: string, cb: WriteCallback): void;
_final(cb: Function): void;
}
This diff is collapsed. Click to expand it.
/// <reference types="node" />
import { EventEmitter } from 'events';
import { Duplex, Readable, Writable } from 'stream';
import { Call, StatusObject } from './call-stream';
import { EmitterAugmentation1 } from './events';
import { Metadata } from './metadata';
import { ObjectReadable, ObjectWritable } from './object-stream';
/**
* A type extending the built-in Error object with additional fields.
*/
export declare type ServiceError = StatusObject & Error;
/**
* A base type for all user-facing values returned by client-side method calls.
*/
export declare type SurfaceCall = {
cancel(): void;
getPeer(): string;
} & EmitterAugmentation1<'metadata', Metadata> & EmitterAugmentation1<'status', StatusObject> & EventEmitter;
/**
* A type representing the return value of a unary method call.
*/
export declare type ClientUnaryCall = SurfaceCall;
/**
* A type representing the return value of a server stream method call.
*/
export declare type ClientReadableStream<ResponseType> = {
deserialize: (chunk: Buffer) => ResponseType;
} & SurfaceCall & ObjectReadable<ResponseType>;
/**
* A type representing the return value of a client stream method call.
*/
export declare type ClientWritableStream<RequestType> = {
serialize: (value: RequestType) => Buffer;
} & SurfaceCall & ObjectWritable<RequestType>;
/**
* A type representing the return value of a bidirectional stream method call.
*/
export declare type ClientDuplexStream<RequestType, ResponseType> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
/**
* Construct a ServiceError from a StatusObject. This function exists primarily
* as an attempt to make the error stack trace clearly communicate that the
* error is not necessarily a problem in gRPC itself.
* @param status
*/
export declare function callErrorFromStatus(status: StatusObject): ServiceError;
export declare class ClientUnaryCallImpl extends EventEmitter implements ClientUnaryCall {
private readonly call;
constructor(call: Call);
cancel(): void;
getPeer(): string;
}
export declare class ClientReadableStreamImpl<ResponseType> extends Readable implements ClientReadableStream<ResponseType> {
private readonly call;
readonly deserialize: (chunk: Buffer) => ResponseType;
constructor(call: Call, deserialize: (chunk: Buffer) => ResponseType);
cancel(): void;
getPeer(): string;
_read(_size: number): void;
}
export declare class ClientWritableStreamImpl<RequestType> extends Writable implements ClientWritableStream<RequestType> {
private readonly call;
readonly serialize: (value: RequestType) => Buffer;
constructor(call: Call, serialize: (value: RequestType) => Buffer);
cancel(): void;
getPeer(): string;
_write(chunk: RequestType, encoding: string, cb: Function): void;
_final(cb: Function): void;
}
export declare class ClientDuplexStreamImpl<RequestType, ResponseType> extends Duplex implements ClientDuplexStream<RequestType, ResponseType> {
private readonly call;
readonly serialize: (value: RequestType) => Buffer;
readonly deserialize: (chunk: Buffer) => ResponseType;
constructor(call: Call, serialize: (value: RequestType) => Buffer, deserialize: (chunk: Buffer) => ResponseType);
cancel(): void;
getPeer(): string;
_read(_size: number): void;
_write(chunk: RequestType, encoding: string, cb: Function): void;
_final(cb: Function): void;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("events");
const stream_1 = require("stream");
const constants_1 = require("./constants");
/**
* Construct a ServiceError from a StatusObject. This function exists primarily
* as an attempt to make the error stack trace clearly communicate that the
* error is not necessarily a problem in gRPC itself.
* @param status
*/
function callErrorFromStatus(status) {
const message = `${status.code} ${constants_1.Status[status.code]}: ${status.details}`;
return Object.assign(new Error(message), status);
}
exports.callErrorFromStatus = callErrorFromStatus;
class ClientUnaryCallImpl extends events_1.EventEmitter {
constructor(call) {
super();
this.call = call;
call.on('metadata', (metadata) => {
this.emit('metadata', metadata);
});
call.on('status', (status) => {
this.emit('status', status);
});
}
cancel() {
this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
}
getPeer() {
return this.call.getPeer();
}
}
exports.ClientUnaryCallImpl = ClientUnaryCallImpl;
function setUpReadableStream(stream, call, deserialize) {
let statusEmitted = false;
call.on('data', (data) => {
let deserialized;
try {
deserialized = deserialize(data);
}
catch (e) {
call.cancelWithStatus(constants_1.Status.INTERNAL, 'Failed to parse server response');
return;
}
if (!stream.push(deserialized)) {
call.pause();
}
});
call.on('end', () => {
if (statusEmitted) {
stream.push(null);
}
else {
call.once('status', () => {
stream.push(null);
});
}
});
call.on('status', (status) => {
if (status.code !== constants_1.Status.OK) {
stream.emit('error', callErrorFromStatus(status));
}
stream.emit('status', status);
statusEmitted = true;
});
call.pause();
}
class ClientReadableStreamImpl extends stream_1.Readable {
constructor(call, deserialize) {
super({ objectMode: true });
this.call = call;
this.deserialize = deserialize;
call.on('metadata', (metadata) => {
this.emit('metadata', metadata);
});
setUpReadableStream(this, call, deserialize);
}
cancel() {
this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
}
getPeer() {
return this.call.getPeer();
}
_read(_size) {
this.call.resume();
}
}
exports.ClientReadableStreamImpl = ClientReadableStreamImpl;
function tryWrite(call, serialize, chunk, encoding, cb) {
let message;
const flags = Number(encoding);
try {
message = serialize(chunk);
}
catch (e) {
call.cancelWithStatus(constants_1.Status.INTERNAL, 'Serialization failure');
cb(e);
return;
}
const writeObj = { message };
if (!Number.isNaN(flags)) {
writeObj.flags = flags;
}
call.write(writeObj, cb);
}
class ClientWritableStreamImpl extends stream_1.Writable {
constructor(call, serialize) {
super({ objectMode: true });
this.call = call;
this.serialize = serialize;
call.on('metadata', (metadata) => {
this.emit('metadata', metadata);
});
call.on('status', (status) => {
this.emit('status', status);
});
}
cancel() {
this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
}
getPeer() {
return this.call.getPeer();
}
_write(chunk, encoding, cb) {
tryWrite(this.call, this.serialize, chunk, encoding, cb);
}
_final(cb) {
this.call.end();
cb();
}
}
exports.ClientWritableStreamImpl = ClientWritableStreamImpl;
class ClientDuplexStreamImpl extends stream_1.Duplex {
constructor(call, serialize, deserialize) {
super({ objectMode: true });
this.call = call;
this.serialize = serialize;
this.deserialize = deserialize;
call.on('metadata', (metadata) => {
this.emit('metadata', metadata);
});
setUpReadableStream(this, call, deserialize);
}
cancel() {
this.call.cancelWithStatus(constants_1.Status.CANCELLED, 'Cancelled on client');
}
getPeer() {
return this.call.getPeer();
}
_read(_size) {
this.call.resume();
}
_write(chunk, encoding, cb) {
tryWrite(this.call, this.serialize, chunk, encoding, cb);
}
_final(cb) {
this.call.end();
cb();
}
}
exports.ClientDuplexStreamImpl = ClientDuplexStreamImpl;
//# sourceMappingURL=call.js.map
\ No newline at end of file
/// <reference types="node" />
import { ConnectionOptions } from 'tls';
import { CallCredentials } from './call-credentials';
/**
* A certificate as received by the checkServerIdentity callback.
*/
export interface Certificate {
/**
* The raw certificate in DER form.
*/
raw: Buffer;
}
/**
* A callback that will receive the expected hostname and presented peer
* certificate as parameters. The callback should return an error to
* indicate that the presented certificate is considered invalid and
* otherwise returned undefined.
*/
export declare type CheckServerIdentityCallback = (hostname: string, cert: Certificate) => Error | undefined;
/**
* Additional peer verification options that can be set when creating
* SSL credentials.
*/
export interface VerifyOptions {
/**
* If set, this callback will be invoked after the usual hostname verification
* has been performed on the peer certificate.
*/
checkServerIdentity?: CheckServerIdentityCallback;
}
/**
* A class that contains credentials for communicating over a channel, as well
* as a set of per-call credentials, which are applied to every method call made
* over a channel initialized with an instance of this class.
*/
export declare abstract class ChannelCredentials {
protected callCredentials: CallCredentials;
protected constructor(callCredentials?: CallCredentials);
/**
* Returns a copy of this object with the included set of per-call credentials
* expanded to include callCredentials.
* @param callCredentials A CallCredentials object to associate with this
* instance.
*/
abstract compose(callCredentials: CallCredentials): ChannelCredentials;
/**
* Gets the set of per-call credentials associated with this instance.
*/
_getCallCredentials(): CallCredentials;
/**
* Gets a SecureContext object generated from input parameters if this
* instance was created with createSsl, or null if this instance was created
* with createInsecure.
*/
abstract _getConnectionOptions(): ConnectionOptions | null;
/**
* Indicates whether this credentials object creates a secure channel.
*/
abstract _isSecure(): boolean;
/**
* Check whether two channel credentials objects are equal. Two secure
* credentials are equal if they were constructed with the same parameters.
* @param other The other ChannelCredentials Object
*/
abstract _equals(other: ChannelCredentials): boolean;
/**
* Return a new ChannelCredentials instance with a given set of credentials.
* The resulting instance can be used to construct a Channel that communicates
* over TLS.
* @param rootCerts The root certificate data.
* @param privateKey The client certificate private key, if available.
* @param certChain The client certificate key chain, if available.
*/
static createSsl(rootCerts?: Buffer | null, privateKey?: Buffer | null, certChain?: Buffer | null, verifyOptions?: VerifyOptions): ChannelCredentials;
/**
* Return a new ChannelCredentials instance with no credentials.
*/
static createInsecure(): ChannelCredentials;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const tls_1 = require("tls");
const call_credentials_1 = require("./call-credentials");
// tslint:disable-next-line:no-any
function verifyIsBufferOrNull(obj, friendlyName) {
if (obj && !(obj instanceof Buffer)) {
throw new TypeError(`${friendlyName}, if provided, must be a Buffer.`);
}
}
function bufferOrNullEqual(buf1, buf2) {
if (buf1 === null && buf2 === null) {
return true;
}
else {
return buf1 !== null && buf2 !== null && buf1.equals(buf2);
}
}
/**
* A class that contains credentials for communicating over a channel, as well
* as a set of per-call credentials, which are applied to every method call made
* over a channel initialized with an instance of this class.
*/
class ChannelCredentials {
constructor(callCredentials) {
this.callCredentials = callCredentials || call_credentials_1.CallCredentials.createEmpty();
}
/**
* Gets the set of per-call credentials associated with this instance.
*/
_getCallCredentials() {
return this.callCredentials;
}
/**
* Return a new ChannelCredentials instance with a given set of credentials.
* The resulting instance can be used to construct a Channel that communicates
* over TLS.
* @param rootCerts The root certificate data.
* @param privateKey The client certificate private key, if available.
* @param certChain The client certificate key chain, if available.
*/
static createSsl(rootCerts, privateKey, certChain, verifyOptions) {
verifyIsBufferOrNull(rootCerts, 'Root certificate');
verifyIsBufferOrNull(privateKey, 'Private key');
verifyIsBufferOrNull(certChain, 'Certificate chain');
if (privateKey && !certChain) {
throw new Error('Private key must be given with accompanying certificate chain');
}
if (!privateKey && certChain) {
throw new Error('Certificate chain must be given with accompanying private key');
}
return new SecureChannelCredentialsImpl(rootCerts || null, privateKey || null, certChain || null, verifyOptions || {});
}
/**
* Return a new ChannelCredentials instance with no credentials.
*/
static createInsecure() {
return new InsecureChannelCredentialsImpl();
}
}
exports.ChannelCredentials = ChannelCredentials;
class InsecureChannelCredentialsImpl extends ChannelCredentials {
constructor(callCredentials) {
super(callCredentials);
}
compose(callCredentials) {
throw new Error('Cannot compose insecure credentials');
}
_getConnectionOptions() {
return null;
}
_isSecure() {
return false;
}
_equals(other) {
return other instanceof InsecureChannelCredentialsImpl;
}
}
class SecureChannelCredentialsImpl extends ChannelCredentials {
constructor(rootCerts, privateKey, certChain, verifyOptions) {
super();
this.rootCerts = rootCerts;
this.privateKey = privateKey;
this.certChain = certChain;
this.verifyOptions = verifyOptions;
const secureContext = tls_1.createSecureContext({
ca: rootCerts || undefined,
key: privateKey || undefined,
cert: certChain || undefined,
});
this.connectionOptions = { secureContext };
if (verifyOptions && verifyOptions.checkServerIdentity) {
this.connectionOptions.checkServerIdentity = (host, cert) => {
return verifyOptions.checkServerIdentity(host, { raw: cert.raw });
};
}
}
compose(callCredentials) {
const combinedCallCredentials = this.callCredentials.compose(callCredentials);
return new ComposedChannelCredentialsImpl(this, combinedCallCredentials);
}
_getConnectionOptions() {
return this.connectionOptions;
}
_isSecure() {
return true;
}
_equals(other) {
if (this === other) {
return true;
}
if (other instanceof SecureChannelCredentialsImpl) {
if (!bufferOrNullEqual(this.rootCerts, other.rootCerts)) {
return false;
}
if (!bufferOrNullEqual(this.privateKey, other.privateKey)) {
return false;
}
if (!bufferOrNullEqual(this.certChain, other.certChain)) {
return false;
}
return (this.verifyOptions.checkServerIdentity ===
other.verifyOptions.checkServerIdentity);
}
else {
return false;
}
}
}
class ComposedChannelCredentialsImpl extends ChannelCredentials {
constructor(channelCredentials, callCreds) {
super(callCreds);
this.channelCredentials = channelCredentials;
}
compose(callCredentials) {
const combinedCallCredentials = this.callCredentials.compose(callCredentials);
return new ComposedChannelCredentialsImpl(this.channelCredentials, combinedCallCredentials);
}
_getConnectionOptions() {
return this.channelCredentials._getConnectionOptions();
}
_isSecure() {
return true;
}
_equals(other) {
if (this === other) {
return true;
}
if (other instanceof ComposedChannelCredentialsImpl) {
return (this.channelCredentials._equals(other.channelCredentials) &&
this.callCredentials._equals(other.callCredentials));
}
else {
return false;
}
}
}
//# sourceMappingURL=channel-credentials.js.map
\ No newline at end of file
/**
* An interface that contains options used when initializing a Channel instance.
*/
export interface ChannelOptions {
'grpc.ssl_target_name_override'?: string;
'grpc.primary_user_agent'?: string;
'grpc.secondary_user_agent'?: string;
'grpc.default_authority'?: string;
'grpc.keepalive_time_ms'?: number;
'grpc.keepalive_timeout_ms'?: number;
[key: string]: string | number | undefined;
}
/**
* This is for checking provided options at runtime. This is an object for
* easier membership checking.
*/
export declare const recognizedOptions: {
'grpc.ssl_target_name_override': boolean;
'grpc.primary_user_agent': boolean;
'grpc.secondary_user_agent': boolean;
'grpc.default_authority': boolean;
'grpc.keepalive_time_ms': boolean;
'grpc.keepalive_timeout_ms': boolean;
};
export declare function channelOptionsEqual(options1: ChannelOptions, options2: ChannelOptions): boolean;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This is for checking provided options at runtime. This is an object for
* easier membership checking.
*/
exports.recognizedOptions = {
'grpc.ssl_target_name_override': true,
'grpc.primary_user_agent': true,
'grpc.secondary_user_agent': true,
'grpc.default_authority': true,
'grpc.keepalive_time_ms': true,
'grpc.keepalive_timeout_ms': true,
};
function channelOptionsEqual(options1, options2) {
const keys1 = Object.keys(options1).sort();
const keys2 = Object.keys(options2).sort();
if (keys1.length !== keys2.length) {
return false;
}
for (let i = 0; i < keys1.length; i += 1) {
if (keys1[i] !== keys2[i]) {
return false;
}
if (options1[keys1[i]] !== options2[keys2[i]]) {
return false;
}
}
return true;
}
exports.channelOptionsEqual = channelOptionsEqual;
//# sourceMappingURL=channel-options.js.map
\ No newline at end of file
import { Deadline, Call, Http2CallStream } from './call-stream';
import { ChannelCredentials } from './channel-credentials';
import { ChannelOptions } from './channel-options';
import { Metadata } from './metadata';
export declare enum ConnectivityState {
CONNECTING = 0,
READY = 1,
TRANSIENT_FAILURE = 2,
IDLE = 3,
SHUTDOWN = 4
}
/**
* An interface that represents a communication channel to a server specified
* by a given address.
*/
export interface Channel {
/**
* Close the channel. This has the same functionality as the existing
* grpc.Client.prototype.close
*/
close(): void;
/**
* Return the target that this channel connects to
*/
getTarget(): string;
/**
* Get the channel's current connectivity state. This method is here mainly
* because it is in the existing internal Channel class, and there isn't
* another good place to put it.
* @param tryToConnect If true, the channel will start connecting if it is
* idle. Otherwise, idle channels will only start connecting when a
* call starts.
*/
getConnectivityState(tryToConnect: boolean): ConnectivityState;
/**
* Watch for connectivity state changes. This is also here mainly because
* it is in the existing external Channel class.
* @param currentState The state to watch for transitions from. This should
* always be populated by calling getConnectivityState immediately
* before.
* @param deadline A deadline for waiting for a state change
* @param callback Called with no error when a state change, or with an
* error if the deadline passes without a state change.
*/
watchConnectivityState(currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void): void;
/**
* Create a call object. Call is an opaque type that is used by the Client
* class. This function is called by the gRPC library when starting a
* request. Implementers should return an instance of Call that is returned
* from calling createCall on an instance of the provided Channel class.
* @param method The full method string to request.
* @param deadline The call deadline
* @param host A host string override for making the request
* @param parentCall A server call to propagate some information from
* @param propagateFlags A bitwise combination of elements of grpc.propagate
* that indicates what information to propagate from parentCall.
*/
createCall(method: string, deadline: Deadline | null | undefined, host: string | null | undefined, parentCall: Call | null | undefined, propagateFlags: number | null | undefined): Call;
}
export declare class ChannelImplementation implements Channel {
private target;
private readonly credentials;
private readonly options;
private resolvingLoadBalancer;
private subchannelPool;
private connectivityState;
private currentPicker;
private pickQueue;
private connectivityStateWatchers;
private defaultAuthority;
private filterStackFactory;
constructor(target: string, credentials: ChannelCredentials, options: ChannelOptions);
/**
* Check the picker output for the given call and corresponding metadata,
* and take any relevant actions. Should not be called while iterating
* over pickQueue.
* @param callStream
* @param callMetadata
*/
private tryPick;
private removeConnectivityStateWatcher;
private updateState;
_startCallStream(stream: Http2CallStream, metadata: Metadata): void;
close(): void;
getTarget(): string;
getConnectivityState(): ConnectivityState;
watchConnectivityState(currentState: ConnectivityState, deadline: Date | number, callback: (error?: Error) => void): void;
createCall(method: string, deadline: Deadline | null | undefined, host: string | null | undefined, parentCall: Call | null | undefined, propagateFlags: number | null | undefined): Call;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const call_stream_1 = require("./call-stream");
const resolving_load_balancer_1 = require("./resolving-load-balancer");
const subchannel_pool_1 = require("./subchannel-pool");
const picker_1 = require("./picker");
const constants_1 = require("./constants");
const filter_stack_1 = require("./filter-stack");
const call_credentials_filter_1 = require("./call-credentials-filter");
const deadline_filter_1 = require("./deadline-filter");
const metadata_status_filter_1 = require("./metadata-status-filter");
const compression_filter_1 = require("./compression-filter");
const resolver_1 = require("./resolver");
const logging_1 = require("./logging");
var ConnectivityState;
(function (ConnectivityState) {
ConnectivityState[ConnectivityState["CONNECTING"] = 0] = "CONNECTING";
ConnectivityState[ConnectivityState["READY"] = 1] = "READY";
ConnectivityState[ConnectivityState["TRANSIENT_FAILURE"] = 2] = "TRANSIENT_FAILURE";
ConnectivityState[ConnectivityState["IDLE"] = 3] = "IDLE";
ConnectivityState[ConnectivityState["SHUTDOWN"] = 4] = "SHUTDOWN";
})(ConnectivityState = exports.ConnectivityState || (exports.ConnectivityState = {}));
class ChannelImplementation {
constructor(target, credentials, options) {
this.target = target;
this.credentials = credentials;
this.options = options;
this.connectivityState = ConnectivityState.IDLE;
this.currentPicker = new picker_1.UnavailablePicker();
this.pickQueue = [];
this.connectivityStateWatchers = [];
// TODO(murgatroid99): check channel arg for getting a private pool
this.subchannelPool = subchannel_pool_1.getSubchannelPool(true);
const channelControlHelper = {
createSubchannel: (subchannelAddress, subchannelArgs) => {
return this.subchannelPool.getOrCreateSubchannel(this.target, subchannelAddress, Object.assign({}, this.options, subchannelArgs), this.credentials);
},
updateState: (connectivityState, picker) => {
this.currentPicker = picker;
const queueCopy = this.pickQueue.slice();
this.pickQueue = [];
for (const { callStream, callMetadata } of queueCopy) {
this.tryPick(callStream, callMetadata);
}
this.updateState(connectivityState);
},
requestReresolution: () => {
// This should never be called.
throw new Error('Resolving load balancer should never call requestReresolution');
},
};
// TODO(murgatroid99): check channel arg for default service config
const defaultServiceConfig = {
loadBalancingConfig: [],
methodConfig: [],
};
this.resolvingLoadBalancer = new resolving_load_balancer_1.ResolvingLoadBalancer(target, channelControlHelper, defaultServiceConfig);
this.filterStackFactory = new filter_stack_1.FilterStackFactory([
new call_credentials_filter_1.CallCredentialsFilterFactory(this),
new deadline_filter_1.DeadlineFilterFactory(this),
new metadata_status_filter_1.MetadataStatusFilterFactory(this),
new compression_filter_1.CompressionFilterFactory(this),
]);
// TODO(murgatroid99): Add more centralized handling of channel options
if (this.options['grpc.default_authority']) {
this.defaultAuthority = this.options['grpc.default_authority'];
}
else {
this.defaultAuthority = resolver_1.getDefaultAuthority(target);
}
}
/**
* Check the picker output for the given call and corresponding metadata,
* and take any relevant actions. Should not be called while iterating
* over pickQueue.
* @param callStream
* @param callMetadata
*/
tryPick(callStream, callMetadata) {
const pickResult = this.currentPicker.pick({ metadata: callMetadata });
switch (pickResult.pickResultType) {
case picker_1.PickResultType.COMPLETE:
if (pickResult.subchannel === null) {
callStream.cancelWithStatus(constants_1.Status.UNAVAILABLE, 'Request dropped by load balancing policy');
// End the call with an error
}
else {
/* If the subchannel disconnects between calling pick and getting
* the filter stack metadata, the call will end with an error. */
callStream.filterStack
.sendMetadata(Promise.resolve(callMetadata))
.then(finalMetadata => {
if (pickResult.subchannel.getConnectivityState() ===
ConnectivityState.READY) {
pickResult.subchannel.startCallStream(finalMetadata, callStream);
}
else {
callStream.cancelWithStatus(constants_1.Status.UNAVAILABLE, 'Connection dropped while starting call');
}
}, (error) => {
// We assume the error code isn't 0 (Status.OK)
callStream.cancelWithStatus(error.code || constants_1.Status.UNKNOWN, `Getting metadata from plugin failed with error: ${error.message}`);
});
}
break;
case picker_1.PickResultType.QUEUE:
this.pickQueue.push({ callStream, callMetadata });
break;
case picker_1.PickResultType.TRANSIENT_FAILURE:
if (callMetadata.getOptions().waitForReady) {
this.pickQueue.push({ callStream, callMetadata });
}
else {
callStream.cancelWithStatus(pickResult.status.code, pickResult.status.details);
}
break;
default:
throw new Error(`Invalid state: unknown pickResultType ${pickResult.pickResultType}`);
}
}
removeConnectivityStateWatcher(watcherObject) {
const watcherIndex = this.connectivityStateWatchers.findIndex(value => value === watcherObject);
if (watcherIndex >= 0) {
this.connectivityStateWatchers.splice(watcherIndex, 1);
}
}
updateState(newState) {
logging_1.trace(constants_1.LogVerbosity.DEBUG, 'connectivity_state', this.target + ' ' + ConnectivityState[this.connectivityState] + ' -> ' + ConnectivityState[newState]);
this.connectivityState = newState;
const watchersCopy = this.connectivityStateWatchers.slice();
for (const watcherObject of watchersCopy) {
if (newState !== watcherObject.currentState) {
watcherObject.callback();
clearTimeout(watcherObject.timer);
this.removeConnectivityStateWatcher(watcherObject);
}
}
}
_startCallStream(stream, metadata) {
this.tryPick(stream, metadata.clone());
}
close() {
this.resolvingLoadBalancer.destroy();
this.updateState(ConnectivityState.SHUTDOWN);
}
getTarget() {
return this.target;
}
getConnectivityState() {
return this.connectivityState;
}
watchConnectivityState(currentState, deadline, callback) {
const deadlineDate = deadline instanceof Date ? deadline : new Date(deadline);
const now = new Date();
if (deadlineDate <= now) {
process.nextTick(callback, new Error('Deadline passed without connectivity state change'));
return;
}
const watcherObject = {
currentState,
callback,
timer: setTimeout(() => {
this.removeConnectivityStateWatcher(watcherObject);
callback(new Error('Deadline passed without connectivity state change'));
}, deadlineDate.getTime() - now.getTime()),
};
this.connectivityStateWatchers.push(watcherObject);
}
createCall(method, deadline, host, parentCall, propagateFlags) {
if (this.connectivityState === ConnectivityState.SHUTDOWN) {
throw new Error('Channel has been shut down');
}
const finalOptions = {
deadline: deadline === null || deadline === undefined ? Infinity : deadline,
flags: propagateFlags || 0,
host: host || this.defaultAuthority,
parentCall: parentCall || null,
};
const stream = new call_stream_1.Http2CallStream(method, this, finalOptions, this.filterStackFactory, this.credentials._getCallCredentials());
return stream;
}
}
exports.ChannelImplementation = ChannelImplementation;
//# sourceMappingURL=channel.js.map
\ No newline at end of file
/// <reference types="node" />
import { ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, ServiceError } from './call';
import { CallCredentials } from './call-credentials';
import { Deadline } from './call-stream';
import { Channel } from './channel';
import { ChannelCredentials } from './channel-credentials';
import { ChannelOptions } from './channel-options';
import { Metadata } from './metadata';
declare const CHANNEL_SYMBOL: unique symbol;
export interface UnaryCallback<ResponseType> {
(err: ServiceError | null, value?: ResponseType): void;
}
export interface CallOptions {
deadline?: Deadline;
host?: string;
propagate_flags?: number;
credentials?: CallCredentials;
}
export declare type ClientOptions = Partial<ChannelOptions> & {
channelOverride?: Channel;
channelFactoryOverride?: (address: string, credentials: ChannelCredentials, options: ClientOptions) => Channel;
};
/**
* A generic gRPC client. Primarily useful as a base class for all generated
* clients.
*/
export declare class Client {
private readonly [CHANNEL_SYMBOL];
constructor(address: string, credentials: ChannelCredentials, options?: ClientOptions);
close(): void;
getChannel(): Channel;
waitForReady(deadline: Deadline, callback: (error?: Error) => void): void;
private handleUnaryResponse;
private checkOptionalUnaryResponseArguments;
makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
makeUnaryRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, callback: UnaryCallback<ResponseType>): ClientUnaryCall;
makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options: CallOptions, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
makeClientStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, callback: UnaryCallback<ResponseType>): ClientWritableStream<RequestType>;
private checkMetadataAndOptions;
makeServerStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, metadata: Metadata, options?: CallOptions): ClientReadableStream<ResponseType>;
makeServerStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, argument: RequestType, options?: CallOptions): ClientReadableStream<ResponseType>;
makeBidiStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, metadata: Metadata, options?: CallOptions): ClientDuplexStream<RequestType, ResponseType>;
makeBidiStreamRequest<RequestType, ResponseType>(method: string, serialize: (value: RequestType) => Buffer, deserialize: (value: Buffer) => ResponseType, options?: CallOptions): ClientDuplexStream<RequestType, ResponseType>;
}
export {};
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const call_1 = require("./call");
const channel_1 = require("./channel");
const constants_1 = require("./constants");
const metadata_1 = require("./metadata");
const CHANNEL_SYMBOL = Symbol();
/**
* A generic gRPC client. Primarily useful as a base class for all generated
* clients.
*/
class Client {
constructor(address, credentials, options = {}) {
if (options.channelOverride) {
this[CHANNEL_SYMBOL] = options.channelOverride;
}
else if (options.channelFactoryOverride) {
this[CHANNEL_SYMBOL] = options.channelFactoryOverride(address, credentials, options);
}
else {
this[CHANNEL_SYMBOL] = new channel_1.ChannelImplementation(address, credentials, options);
}
}
close() {
this[CHANNEL_SYMBOL].close();
}
getChannel() {
return this[CHANNEL_SYMBOL];
}
waitForReady(deadline, callback) {
const checkState = (err) => {
if (err) {
callback(new Error('Failed to connect before the deadline'));
return;
}
let newState;
try {
newState = this[CHANNEL_SYMBOL].getConnectivityState(true);
}
catch (e) {
callback(new Error('The channel has been closed'));
return;
}
if (newState === channel_1.ConnectivityState.READY) {
callback();
}
else {
try {
this[CHANNEL_SYMBOL].watchConnectivityState(newState, deadline, checkState);
}
catch (e) {
callback(new Error('The channel has been closed'));
}
}
};
setImmediate(checkState);
}
handleUnaryResponse(call, deserialize, callback) {
let responseMessage = null;
call.on('data', (data) => {
if (responseMessage != null) {
call.cancelWithStatus(constants_1.Status.INTERNAL, 'Too many responses received');
}
try {
responseMessage = deserialize(data);
}
catch (e) {
call.cancelWithStatus(constants_1.Status.INTERNAL, 'Failed to parse server response');
}
});
call.on('status', (status) => {
/* We assume that call emits status after it emits end, and that it
* accounts for any cancelWithStatus calls up until it emits status.
* Therefore, considering the above event handlers, status.code should be
* OK if and only if we have a non-null responseMessage */
if (status.code === constants_1.Status.OK) {
callback(null, responseMessage);
}
else {
callback(call_1.callErrorFromStatus(status));
}
});
}
checkOptionalUnaryResponseArguments(arg1, arg2, arg3) {
if (arg1 instanceof Function) {
return { metadata: new metadata_1.Metadata(), options: {}, callback: arg1 };
}
else if (arg2 instanceof Function) {
if (arg1 instanceof metadata_1.Metadata) {
return { metadata: arg1, options: {}, callback: arg2 };
}
else {
return { metadata: new metadata_1.Metadata(), options: arg1, callback: arg2 };
}
}
else {
if (!(arg1 instanceof metadata_1.Metadata &&
arg2 instanceof Object &&
arg3 instanceof Function)) {
throw new Error('Incorrect arguments passed');
}
return { metadata: arg1, options: arg2, callback: arg3 };
}
}
makeUnaryRequest(method, serialize, deserialize, argument, metadata, options, callback) {
({ metadata, options, callback } = this.checkOptionalUnaryResponseArguments(metadata, options, callback));
const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
const message = serialize(argument);
const writeObj = { message };
call.sendMetadata(metadata);
call.write(writeObj);
call.end();
this.handleUnaryResponse(call, deserialize, callback);
return new call_1.ClientUnaryCallImpl(call);
}
makeClientStreamRequest(method, serialize, deserialize, metadata, options, callback) {
({ metadata, options, callback } = this.checkOptionalUnaryResponseArguments(metadata, options, callback));
const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
call.sendMetadata(metadata);
this.handleUnaryResponse(call, deserialize, callback);
return new call_1.ClientWritableStreamImpl(call, serialize);
}
checkMetadataAndOptions(arg1, arg2) {
let metadata;
let options;
if (arg1 instanceof metadata_1.Metadata) {
metadata = arg1;
if (arg2) {
options = arg2;
}
else {
options = {};
}
}
else {
if (arg1) {
options = arg1;
}
else {
options = {};
}
metadata = new metadata_1.Metadata();
}
return { metadata, options };
}
makeServerStreamRequest(method, serialize, deserialize, argument, metadata, options) {
({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
const message = serialize(argument);
const writeObj = { message };
call.sendMetadata(metadata);
call.write(writeObj);
call.end();
return new call_1.ClientReadableStreamImpl(call, deserialize);
}
makeBidiStreamRequest(method, serialize, deserialize, metadata, options) {
({ metadata, options } = this.checkMetadataAndOptions(metadata, options));
const call = this[CHANNEL_SYMBOL].createCall(method, options.deadline, options.host, null, options.propagate_flags);
if (options.credentials) {
call.setCredentials(options.credentials);
}
call.sendMetadata(metadata);
return new call_1.ClientDuplexStreamImpl(call, serialize, deserialize);
}
}
exports.Client = Client;
//# sourceMappingURL=client.js.map
\ No newline at end of file
/// <reference types="node" />
import { Call, WriteObject } from './call-stream';
import { Channel } from './channel';
import { BaseFilter, Filter, FilterFactory } from './filter';
import { Metadata } from './metadata';
export declare class CompressionFilter extends BaseFilter implements Filter {
private sendCompression;
private receiveCompression;
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
}
export declare class CompressionFilterFactory implements FilterFactory<CompressionFilter> {
private readonly channel;
constructor(channel: Channel);
createFilter(callStream: Call): CompressionFilter;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const zlib = require("zlib");
const filter_1 = require("./filter");
class CompressionHandler {
/**
* @param message Raw uncompressed message bytes
* @param compress Indicates whether the message should be compressed
* @return Framed message, compressed if applicable
*/
async writeMessage(message, compress) {
let messageBuffer = message;
if (compress) {
messageBuffer = await this.compressMessage(messageBuffer);
}
const output = Buffer.allocUnsafe(messageBuffer.length + 5);
output.writeUInt8(compress ? 1 : 0, 0);
output.writeUInt32BE(messageBuffer.length, 1);
messageBuffer.copy(output, 5);
return output;
}
/**
* @param data Framed message, possibly compressed
* @return Uncompressed message
*/
async readMessage(data) {
const compressed = data.readUInt8(0) === 1;
let messageBuffer = data.slice(5);
if (compressed) {
messageBuffer = await this.decompressMessage(messageBuffer);
}
return messageBuffer;
}
}
class IdentityHandler extends CompressionHandler {
async compressMessage(message) {
return message;
}
async writeMessage(message, compress) {
const output = Buffer.allocUnsafe(message.length + 5);
/* With "identity" compression, messages should always be marked as
* uncompressed */
output.writeUInt8(0, 0);
output.writeUInt32BE(message.length, 1);
message.copy(output, 5);
return output;
}
decompressMessage(message) {
return Promise.reject(new Error('Received compressed message but "grpc-encoding" header was identity'));
}
}
class DeflateHandler extends CompressionHandler {
compressMessage(message) {
return new Promise((resolve, reject) => {
zlib.deflate(message, (err, output) => {
if (err) {
reject(err);
}
else {
resolve(output);
}
});
});
}
decompressMessage(message) {
return new Promise((resolve, reject) => {
zlib.inflate(message, (err, output) => {
if (err) {
reject(err);
}
else {
resolve(output);
}
});
});
}
}
class GzipHandler extends CompressionHandler {
compressMessage(message) {
return new Promise((resolve, reject) => {
zlib.gzip(message, (err, output) => {
if (err) {
reject(err);
}
else {
resolve(output);
}
});
});
}
decompressMessage(message) {
return new Promise((resolve, reject) => {
zlib.unzip(message, (err, output) => {
if (err) {
reject(err);
}
else {
resolve(output);
}
});
});
}
}
class UnknownHandler extends CompressionHandler {
constructor(compressionName) {
super();
this.compressionName = compressionName;
}
compressMessage(message) {
return Promise.reject(new Error(`Received message compressed with unsupported compression method ${this.compressionName}`));
}
decompressMessage(message) {
// This should be unreachable
return Promise.reject(new Error(`Compression method not supported: ${this.compressionName}`));
}
}
function getCompressionHandler(compressionName) {
switch (compressionName) {
case 'identity':
return new IdentityHandler();
case 'deflate':
return new DeflateHandler();
case 'gzip':
return new GzipHandler();
default:
return new UnknownHandler(compressionName);
}
}
class CompressionFilter extends filter_1.BaseFilter {
constructor() {
super(...arguments);
this.sendCompression = new IdentityHandler();
this.receiveCompression = new IdentityHandler();
}
async sendMetadata(metadata) {
const headers = await metadata;
headers.set('grpc-encoding', 'identity');
headers.set('grpc-accept-encoding', 'identity,deflate,gzip');
return headers;
}
async receiveMetadata(metadata) {
const headers = await metadata;
const receiveEncoding = headers.get('grpc-encoding');
if (receiveEncoding.length > 0) {
const encoding = receiveEncoding[0];
if (typeof encoding === 'string') {
this.receiveCompression = getCompressionHandler(encoding);
}
}
headers.remove('grpc-encoding');
headers.remove('grpc-accept-encoding');
return headers;
}
async sendMessage(message) {
/* This filter is special. The input message is the bare message bytes,
* and the output is a framed and possibly compressed message. For this
* reason, this filter should be at the bottom of the filter stack */
const resolvedMessage = await message;
const compress = resolvedMessage.flags === undefined
? false
: (resolvedMessage.flags & 2 /* NoCompress */) === 0;
return {
message: await this.sendCompression.writeMessage(resolvedMessage.message, compress),
flags: resolvedMessage.flags,
};
}
async receiveMessage(message) {
/* This filter is also special. The input message is framed and possibly
* compressed, and the output message is deframed and uncompressed. So
* this is another reason that this filter should be at the bottom of the
* filter stack. */
return this.receiveCompression.readMessage(await message);
}
}
exports.CompressionFilter = CompressionFilter;
class CompressionFilterFactory {
constructor(channel) {
this.channel = channel;
}
createFilter(callStream) {
return new CompressionFilter();
}
}
exports.CompressionFilterFactory = CompressionFilterFactory;
//# sourceMappingURL=compression-filter.js.map
\ No newline at end of file
export declare enum Status {
OK = 0,
CANCELLED = 1,
UNKNOWN = 2,
INVALID_ARGUMENT = 3,
DEADLINE_EXCEEDED = 4,
NOT_FOUND = 5,
ALREADY_EXISTS = 6,
PERMISSION_DENIED = 7,
RESOURCE_EXHAUSTED = 8,
FAILED_PRECONDITION = 9,
ABORTED = 10,
OUT_OF_RANGE = 11,
UNIMPLEMENTED = 12,
INTERNAL = 13,
UNAVAILABLE = 14,
DATA_LOSS = 15,
UNAUTHENTICATED = 16
}
export declare enum LogVerbosity {
DEBUG = 0,
INFO = 1,
ERROR = 2
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Status;
(function (Status) {
Status[Status["OK"] = 0] = "OK";
Status[Status["CANCELLED"] = 1] = "CANCELLED";
Status[Status["UNKNOWN"] = 2] = "UNKNOWN";
Status[Status["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
Status[Status["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
Status[Status["NOT_FOUND"] = 5] = "NOT_FOUND";
Status[Status["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
Status[Status["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
Status[Status["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
Status[Status["FAILED_PRECONDITION"] = 9] = "FAILED_PRECONDITION";
Status[Status["ABORTED"] = 10] = "ABORTED";
Status[Status["OUT_OF_RANGE"] = 11] = "OUT_OF_RANGE";
Status[Status["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
Status[Status["INTERNAL"] = 13] = "INTERNAL";
Status[Status["UNAVAILABLE"] = 14] = "UNAVAILABLE";
Status[Status["DATA_LOSS"] = 15] = "DATA_LOSS";
Status[Status["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
})(Status = exports.Status || (exports.Status = {}));
var LogVerbosity;
(function (LogVerbosity) {
LogVerbosity[LogVerbosity["DEBUG"] = 0] = "DEBUG";
LogVerbosity[LogVerbosity["INFO"] = 1] = "INFO";
LogVerbosity[LogVerbosity["ERROR"] = 2] = "ERROR";
})(LogVerbosity = exports.LogVerbosity || (exports.LogVerbosity = {}));
//# sourceMappingURL=constants.js.map
\ No newline at end of file
import { Call } from './call-stream';
import { Channel } from './channel';
import { BaseFilter, Filter, FilterFactory } from './filter';
import { Metadata } from './metadata';
export declare class DeadlineFilter extends BaseFilter implements Filter {
private readonly channel;
private readonly callStream;
private timer;
private deadline;
constructor(channel: Channel, callStream: Call);
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
}
export declare class DeadlineFilterFactory implements FilterFactory<DeadlineFilter> {
private readonly channel;
constructor(channel: Channel);
createFilter(callStream: Call): DeadlineFilter;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
const filter_1 = require("./filter");
const units = [
['m', 1],
['S', 1000],
['M', 60 * 1000],
['H', 60 * 60 * 1000],
];
function getDeadline(deadline) {
const now = new Date().getTime();
const timeoutMs = Math.max(deadline - now, 0);
for (const [unit, factor] of units) {
const amount = timeoutMs / factor;
if (amount < 1e8) {
return String(Math.ceil(amount)) + unit;
}
}
throw new Error('Deadline is too far in the future');
}
class DeadlineFilter extends filter_1.BaseFilter {
constructor(channel, callStream) {
super();
this.channel = channel;
this.callStream = callStream;
this.timer = null;
const callDeadline = callStream.getDeadline();
if (callDeadline instanceof Date) {
this.deadline = callDeadline.getTime();
}
else {
this.deadline = callDeadline;
}
const now = new Date().getTime();
let timeout = this.deadline - now;
if (timeout < 0) {
timeout = 0;
}
if (this.deadline !== Infinity) {
this.timer = setTimeout(() => {
callStream.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, 'Deadline exceeded');
}, timeout);
callStream.on('status', () => clearTimeout(this.timer));
}
}
async sendMetadata(metadata) {
if (this.deadline === Infinity) {
return metadata;
}
/* The input metadata promise depends on the original channel.connect()
* promise, so when it is complete that implies that the channel is
* connected */
const finalMetadata = await metadata;
const timeoutString = getDeadline(this.deadline);
finalMetadata.set('grpc-timeout', timeoutString);
return finalMetadata;
}
}
exports.DeadlineFilter = DeadlineFilter;
class DeadlineFilterFactory {
constructor(channel) {
this.channel = channel;
}
createFilter(callStream) {
return new DeadlineFilter(this.channel, callStream);
}
}
exports.DeadlineFilterFactory = DeadlineFilterFactory;
//# sourceMappingURL=deadline-filter.js.map
\ No newline at end of file
export interface EmitterAugmentation1<Name extends string | symbol, Arg> {
addListener(event: Name, listener: (arg1: Arg) => void): this;
emit(event: Name, arg1: Arg): boolean;
on(event: Name, listener: (arg1: Arg) => void): this;
once(event: Name, listener: (arg1: Arg) => void): this;
prependListener(event: Name, listener: (arg1: Arg) => void): this;
prependOnceListener(event: Name, listener: (arg1: Arg) => void): this;
removeListener(event: Name, listener: (arg1: Arg) => void): this;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=events.js.map
\ No newline at end of file
/// <reference types="node" />
import { Call, StatusObject, WriteObject } from './call-stream';
import { Filter, FilterFactory } from './filter';
import { Metadata } from './metadata';
export declare class FilterStack implements Filter {
private readonly filters;
constructor(filters: Filter[]);
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
}
export declare class FilterStackFactory implements FilterFactory<FilterStack> {
private readonly factories;
constructor(factories: Array<FilterFactory<Filter>>);
createFilter(callStream: Call): FilterStack;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
class FilterStack {
constructor(filters) {
this.filters = filters;
}
sendMetadata(metadata) {
let result = metadata;
for (let i = 0; i < this.filters.length; i++) {
result = this.filters[i].sendMetadata(result);
}
return result;
}
receiveMetadata(metadata) {
let result = metadata;
for (let i = this.filters.length - 1; i >= 0; i--) {
result = this.filters[i].receiveMetadata(result);
}
return result;
}
sendMessage(message) {
let result = message;
for (let i = 0; i < this.filters.length; i++) {
result = this.filters[i].sendMessage(result);
}
return result;
}
receiveMessage(message) {
let result = message;
for (let i = this.filters.length - 1; i >= 0; i--) {
result = this.filters[i].receiveMessage(result);
}
return result;
}
receiveTrailers(status) {
let result = status;
for (let i = this.filters.length - 1; i >= 0; i--) {
result = this.filters[i].receiveTrailers(result);
}
return result;
}
}
exports.FilterStack = FilterStack;
class FilterStackFactory {
constructor(factories) {
this.factories = factories;
}
createFilter(callStream) {
return new FilterStack(this.factories.map(factory => factory.createFilter(callStream)));
}
}
exports.FilterStackFactory = FilterStackFactory;
//# sourceMappingURL=filter-stack.js.map
\ No newline at end of file
/// <reference types="node" />
import { Call, StatusObject, WriteObject } from './call-stream';
import { Metadata } from './metadata';
/**
* Filter classes represent related per-call logic and state that is primarily
* used to modify incoming and outgoing data
*/
export interface Filter {
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
}
export declare abstract class BaseFilter {
sendMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
receiveMetadata(metadata: Promise<Metadata>): Promise<Metadata>;
sendMessage(message: Promise<WriteObject>): Promise<WriteObject>;
receiveMessage(message: Promise<Buffer>): Promise<Buffer>;
receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
}
export interface FilterFactory<T extends Filter> {
createFilter(callStream: Call): T;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
class BaseFilter {
async sendMetadata(metadata) {
return metadata;
}
async receiveMetadata(metadata) {
return metadata;
}
async sendMessage(message) {
return message;
}
async receiveMessage(message) {
return message;
}
async receiveTrailers(status) {
return status;
}
}
exports.BaseFilter = BaseFilter;
//# sourceMappingURL=filter.js.map
\ No newline at end of file
/// <reference types="node" />
import { ClientDuplexStream, ClientReadableStream, ClientUnaryCall, ClientWritableStream, ServiceError } from './call';
import { CallCredentials } from './call-credentials';
import { Deadline, StatusObject } from './call-stream';
import { Channel, ConnectivityState, ChannelImplementation } from './channel';
import { ChannelCredentials } from './channel-credentials';
import { CallOptions, Client } from './client';
import { LogVerbosity, Status } from './constants';
import { Deserialize, loadPackageDefinition, makeClientConstructor, Serialize, ServiceDefinition } from './make-client';
import { Metadata } from './metadata';
import { Server, UntypedHandleCall, UntypedServiceImplementation } from './server';
import { KeyCertPair, ServerCredentials } from './server-credentials';
import { StatusBuilder } from './status-builder';
import { handleBidiStreamingCall, handleServerStreamingCall, handleUnaryCall, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream } from './server-call';
export interface OAuth2Client {
getRequestMetadata: (url: string, callback: (err: Error | null, headers?: {
Authorization: string;
}) => void) => void;
getRequestHeaders: (url?: string) => Promise<{
Authorization: string;
}>;
}
/**** Client Credentials ****/
export declare const credentials: {
[key: string]: Function;
};
/**** Metadata ****/
export { Metadata };
/**** Constants ****/
export { LogVerbosity as logVerbosity, Status as status, ConnectivityState as connectivityState, };
/**** Client ****/
export { Client, loadPackageDefinition, makeClientConstructor, makeClientConstructor as makeGenericClientConstructor, ChannelImplementation as Channel, };
/**
* Close a Client object.
* @param client The client to close.
*/
export declare const closeClient: (client: Client) => void;
export declare const waitForClientReady: (client: Client, deadline: number | Date, callback: (error?: Error | undefined) => void) => void;
export { ChannelCredentials, CallCredentials, Deadline, Serialize as serialize, Deserialize as deserialize, ClientUnaryCall, ClientReadableStream, ClientWritableStream, ClientDuplexStream, CallOptions, StatusObject, ServiceError, ServerUnaryCall, ServerReadableStream, ServerWritableStream, ServerDuplexStream, ServiceDefinition, UntypedHandleCall, UntypedServiceImplementation, };
/**** Server ****/
export { handleBidiStreamingCall, handleServerStreamingCall, handleUnaryCall, };
export declare type Call = ClientUnaryCall | ClientReadableStream<any> | ClientWritableStream<any> | ClientDuplexStream<any, any>;
export declare type MetadataListener = (metadata: Metadata, next: Function) => void;
export declare type MessageListener = (message: any, next: Function) => void;
export declare type StatusListener = (status: StatusObject, next: Function) => void;
export interface Listener {
onReceiveMetadata?: MetadataListener;
onReceiveMessage?: MessageListener;
onReceiveStatus?: StatusListener;
}
/**** Unimplemented function stubs ****/
export declare const loadObject: (value: any, options: any) => never;
export declare const load: (filename: any, format: any, options: any) => never;
export declare const setLogger: (logger: Partial<Console>) => void;
export declare const setLogVerbosity: (verbosity: LogVerbosity) => void;
export { Server };
export { ServerCredentials };
export { KeyCertPair };
export declare const getClientChannel: (client: Client) => Channel;
export { StatusBuilder };
export declare const ListenerBuilder: () => never;
export declare const InterceptorBuilder: () => never;
export declare const InterceptingCall: () => never;
export { GrpcObject } from './make-client';
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const semver = require("semver");
const call_credentials_1 = require("./call-credentials");
exports.CallCredentials = call_credentials_1.CallCredentials;
const channel_1 = require("./channel");
exports.connectivityState = channel_1.ConnectivityState;
exports.Channel = channel_1.ChannelImplementation;
const channel_credentials_1 = require("./channel-credentials");
exports.ChannelCredentials = channel_credentials_1.ChannelCredentials;
const client_1 = require("./client");
exports.Client = client_1.Client;
const constants_1 = require("./constants");
exports.logVerbosity = constants_1.LogVerbosity;
exports.status = constants_1.Status;
const logging = require("./logging");
const make_client_1 = require("./make-client");
exports.loadPackageDefinition = make_client_1.loadPackageDefinition;
exports.makeClientConstructor = make_client_1.makeClientConstructor;
exports.makeGenericClientConstructor = make_client_1.makeClientConstructor;
const metadata_1 = require("./metadata");
exports.Metadata = metadata_1.Metadata;
const server_1 = require("./server");
exports.Server = server_1.Server;
const server_credentials_1 = require("./server-credentials");
exports.ServerCredentials = server_credentials_1.ServerCredentials;
const status_builder_1 = require("./status-builder");
exports.StatusBuilder = status_builder_1.StatusBuilder;
const supportedNodeVersions = require('../../package.json').engines.node;
if (!semver.satisfies(process.version, supportedNodeVersions)) {
throw new Error(`@grpc/grpc-js only works on Node ${supportedNodeVersions}`);
}
function mixin(...sources) {
const result = {};
for (const source of sources) {
for (const propName of Object.getOwnPropertyNames(source)) {
const property = source[propName]; // tslint:disable-line no-any
if (typeof property === 'function') {
result[propName] = property;
}
}
}
return result;
}
/**** Client Credentials ****/
// Using assign only copies enumerable properties, which is what we want
exports.credentials = mixin({
/**
* Create a gRPC credential from a Google credential object.
* @param googleCredentials The authentication client to use.
* @return The resulting CallCredentials object.
*/
createFromGoogleCredential: (googleCredentials) => {
return call_credentials_1.CallCredentials.createFromMetadataGenerator((options, callback) => {
// google-auth-library pre-v2.0.0 does not have getRequestHeaders
// but has getRequestMetadata, which is deprecated in v2.0.0
let getHeaders;
if (typeof googleCredentials.getRequestHeaders === 'function') {
getHeaders = googleCredentials.getRequestHeaders(options.service_url);
}
else {
getHeaders = new Promise((resolve, reject) => {
googleCredentials.getRequestMetadata(options.service_url, (err, headers) => {
if (err) {
reject(err);
return;
}
resolve(headers);
});
});
}
getHeaders.then(headers => {
const metadata = new metadata_1.Metadata();
metadata.add('authorization', headers.Authorization);
callback(null, metadata);
}, err => {
callback(err);
});
});
},
/**
* Combine a ChannelCredentials with any number of CallCredentials into a
* single ChannelCredentials object.
* @param channelCredentials The ChannelCredentials object.
* @param callCredentials Any number of CallCredentials objects.
* @return The resulting ChannelCredentials object.
*/
combineChannelCredentials: (channelCredentials, ...callCredentials) => {
return callCredentials.reduce((acc, other) => acc.compose(other), channelCredentials);
},
/**
* Combine any number of CallCredentials into a single CallCredentials
* object.
* @param first The first CallCredentials object.
* @param additional Any number of additional CallCredentials objects.
* @return The resulting CallCredentials object.
*/
combineCallCredentials: (first, ...additional) => {
return additional.reduce((acc, other) => acc.compose(other), first);
},
}, channel_credentials_1.ChannelCredentials, call_credentials_1.CallCredentials);
/**
* Close a Client object.
* @param client The client to close.
*/
exports.closeClient = (client) => client.close();
exports.waitForClientReady = (client, deadline, callback) => client.waitForReady(deadline, callback);
/**** Unimplemented function stubs ****/
/* tslint:disable:no-any variable-name */
exports.loadObject = (value, options) => {
throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
};
exports.load = (filename, format, options) => {
throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
};
exports.setLogger = (logger) => {
logging.setLogger(logger);
};
exports.setLogVerbosity = (verbosity) => {
logging.setLoggerVerbosity(verbosity);
};
exports.getClientChannel = (client) => {
return client_1.Client.prototype.getChannel.call(client);
};
exports.ListenerBuilder = () => {
throw new Error('Not yet implemented');
};
exports.InterceptorBuilder = () => {
throw new Error('Not yet implemented');
};
exports.InterceptingCall = () => {
throw new Error('Not yet implemented');
};
const resolver = require("./resolver");
const load_balancer = require("./load-balancer");
(() => {
resolver.registerAll();
load_balancer.registerAll();
})();
//# sourceMappingURL=index.js.map
\ No newline at end of file
import { LoadBalancer, ChannelControlHelper } from './load-balancer';
import { LoadBalancingConfig } from './load-balancing-config';
export declare class PickFirstLoadBalancer implements LoadBalancer {
private channelControlHelper;
/**
* The list of backend addresses most recently passed to `updateAddressList`.
*/
private latestAddressList;
/**
* The list of subchannels this load balancer is currently attempting to
* connect to.
*/
private subchannels;
/**
* The current connectivity state of the load balancer.
*/
private currentState;
/**
* The index within the `subchannels` array of the subchannel with the most
* recently started connection attempt.
*/
private currentSubchannelIndex;
private subchannelStateCounts;
/**
* The currently picked subchannel used for making calls. Populated if
* and only if the load balancer's current state is READY. In that case,
* the subchannel's current state is also READY.
*/
private currentPick;
/**
* Listener callback attached to each subchannel in the `subchannels` list
* while establishing a connection.
*/
private subchannelStateListener;
/**
* Listener callback attached to the current picked subchannel.
*/
private pickedSubchannelStateListener;
/**
* Timer reference for the timer tracking when to start
*/
private connectionDelayTimeout;
private triedAllSubchannels;
/**
* Load balancer that attempts to connect to each backend in the address list
* in order, and picks the first one that connects, using it for every
* request.
* @param channelControlHelper `ChannelControlHelper` instance provided by
* this load balancer's owner.
*/
constructor(channelControlHelper: ChannelControlHelper);
private startNextSubchannelConnecting;
/**
* Have a single subchannel in the `subchannels` list start connecting.
* @param subchannelIndex The index into the `subchannels` list.
*/
private startConnecting;
private pickSubchannel;
private updateState;
private resetSubchannelList;
/**
* Start connecting to the address list most recently passed to
* `updateAddressList`.
*/
private connectToAddressList;
updateAddressList(addressList: string[], lbConfig: LoadBalancingConfig | null): void;
exitIdle(): void;
resetBackoff(): void;
destroy(): void;
getTypeName(): string;
replaceChannelControlHelper(channelControlHelper: ChannelControlHelper): void;
}
export declare function setup(): void;
This diff is collapsed. Click to expand it.
import { LoadBalancer, ChannelControlHelper } from './load-balancer';
import { LoadBalancingConfig } from './load-balancing-config';
export declare class RoundRobinLoadBalancer implements LoadBalancer {
private channelControlHelper;
private subchannels;
private currentState;
private subchannelStateListener;
private subchannelStateCounts;
private currentReadyPicker;
constructor(channelControlHelper: ChannelControlHelper);
private calculateAndUpdateState;
private updateState;
private resetSubchannelList;
updateAddressList(addressList: string[], lbConfig: LoadBalancingConfig | null): void;
exitIdle(): void;
resetBackoff(): void;
destroy(): void;
getTypeName(): string;
replaceChannelControlHelper(channelControlHelper: ChannelControlHelper): void;
}
export declare function setup(): void;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const load_balancer_1 = require("./load-balancer");
const channel_1 = require("./channel");
const picker_1 = require("./picker");
const TYPE_NAME = 'round_robin';
class RoundRobinPicker {
constructor(subchannelList, nextIndex = 0) {
this.subchannelList = subchannelList;
this.nextIndex = nextIndex;
}
pick(pickArgs) {
const pickedSubchannel = this.subchannelList[this.nextIndex];
this.nextIndex = (this.nextIndex + 1) % this.subchannelList.length;
return {
pickResultType: picker_1.PickResultType.COMPLETE,
subchannel: pickedSubchannel,
status: null
};
}
/**
* Check what the next subchannel returned would be. Used by the load
* balancer implementation to preserve this part of the picker state if
* possible when a subchannel connects or disconnects.
*/
peekNextSubchannel() {
return this.subchannelList[this.nextIndex];
}
}
class RoundRobinLoadBalancer {
constructor(channelControlHelper) {
this.channelControlHelper = channelControlHelper;
this.subchannels = [];
this.currentState = channel_1.ConnectivityState.IDLE;
this.currentReadyPicker = null;
console.log('Using round robin load balancer');
this.updateState(channel_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
this.subchannelStateCounts = {
[channel_1.ConnectivityState.CONNECTING]: 0,
[channel_1.ConnectivityState.IDLE]: 0,
[channel_1.ConnectivityState.READY]: 0,
[channel_1.ConnectivityState.SHUTDOWN]: 0,
[channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0
};
this.subchannelStateListener = (subchannel, previousState, newState) => {
this.subchannelStateCounts[previousState] -= 1;
this.subchannelStateCounts[newState] += 1;
this.calculateAndUpdateState();
if (newState === channel_1.ConnectivityState.TRANSIENT_FAILURE) {
this.channelControlHelper.requestReresolution();
}
if (newState === channel_1.ConnectivityState.TRANSIENT_FAILURE || newState === channel_1.ConnectivityState.IDLE) {
subchannel.startConnecting();
}
};
}
calculateAndUpdateState() {
if (this.subchannelStateCounts[channel_1.ConnectivityState.READY] > 0) {
const readySubchannels = this.subchannels.filter(subchannel => subchannel.getConnectivityState() === channel_1.ConnectivityState.READY);
let index = 0;
if (this.currentReadyPicker !== null) {
index = readySubchannels.indexOf(this.currentReadyPicker.peekNextSubchannel());
if (index < 0) {
index = 0;
}
}
this.updateState(channel_1.ConnectivityState.READY, new RoundRobinPicker(readySubchannels, index));
}
else if (this.subchannelStateCounts[channel_1.ConnectivityState.CONNECTING] > 0) {
this.updateState(channel_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this));
}
else if (this.subchannelStateCounts[channel_1.ConnectivityState.TRANSIENT_FAILURE] > 0) {
this.updateState(channel_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker());
}
else {
this.updateState(channel_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
}
}
updateState(newState, picker) {
if (newState === channel_1.ConnectivityState.READY) {
this.currentReadyPicker = picker;
}
else {
this.currentReadyPicker = null;
}
this.currentState = newState;
this.channelControlHelper.updateState(newState, picker);
}
resetSubchannelList() {
for (const subchannel of this.subchannels) {
subchannel.removeConnectivityStateListener(this.subchannelStateListener);
subchannel.unref();
}
this.subchannelStateCounts = {
[channel_1.ConnectivityState.CONNECTING]: 0,
[channel_1.ConnectivityState.IDLE]: 0,
[channel_1.ConnectivityState.READY]: 0,
[channel_1.ConnectivityState.SHUTDOWN]: 0,
[channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0
};
this.subchannels = [];
}
updateAddressList(addressList, lbConfig) {
this.resetSubchannelList();
this.subchannels = addressList.map(address => this.channelControlHelper.createSubchannel(address, {}));
for (const subchannel of this.subchannels) {
const subchannelState = subchannel.getConnectivityState();
this.subchannelStateCounts[subchannelState] += 1;
if (subchannelState === channel_1.ConnectivityState.IDLE || subchannelState === channel_1.ConnectivityState.TRANSIENT_FAILURE) {
subchannel.startConnecting();
}
}
this.calculateAndUpdateState();
}
exitIdle() {
for (const subchannel of this.subchannels) {
subchannel.startConnecting();
}
}
resetBackoff() {
/* The pick first load balancer does not have a connection backoff, so this
* does nothing */
}
destroy() {
this.resetSubchannelList();
}
getTypeName() {
return TYPE_NAME;
}
replaceChannelControlHelper(channelControlHelper) {
this.channelControlHelper = channelControlHelper;
}
}
exports.RoundRobinLoadBalancer = RoundRobinLoadBalancer;
function setup() {
load_balancer_1.registerLoadBalancerType(TYPE_NAME, RoundRobinLoadBalancer);
}
exports.setup = setup;
//# sourceMappingURL=load-balancer-round-robin.js.map
\ No newline at end of file
import { ChannelOptions } from './channel-options';
import { Subchannel } from './subchannel';
import { ConnectivityState } from './channel';
import { Picker } from './picker';
import { LoadBalancingConfig } from './load-balancing-config';
/**
* A collection of functions associated with a channel that a load balancer
* can call as necessary.
*/
export interface ChannelControlHelper {
/**
* Returns a subchannel connected to the specified address.
* @param subchannelAddress The address to connect to
* @param subchannelArgs Extra channel arguments specified by the load balancer
*/
createSubchannel(subchannelAddress: string, subchannelArgs: ChannelOptions): Subchannel;
/**
* Passes a new subchannel picker up to the channel. This is called if either
* the connectivity state changes or if a different picker is needed for any
* other reason.
* @param connectivityState New connectivity state
* @param picker New picker
*/
updateState(connectivityState: ConnectivityState, picker: Picker): void;
/**
* Request new data from the resolver.
*/
requestReresolution(): void;
}
/**
* Tracks one or more connected subchannels and determines which subchannel
* each request should use.
*/
export interface LoadBalancer {
/**
* Gives the load balancer a new list of addresses to start connecting to.
* The load balancer will start establishing connections with the new list,
* but will continue using any existing connections until the new connections
* are established
* @param addressList The new list of addresses to connect to
* @param lbConfig The load balancing config object from the service config,
* if one was provided
*/
updateAddressList(addressList: string[], lbConfig: LoadBalancingConfig | null): void;
/**
* If the load balancer is currently in the IDLE state, start connecting.
*/
exitIdle(): void;
/**
* If the load balancer is currently in the CONNECTING or TRANSIENT_FAILURE
* state, reset the current connection backoff timeout to its base value and
* transition to CONNECTING if in TRANSIENT_FAILURE.
*/
resetBackoff(): void;
/**
* The load balancer unrefs all of its subchannels and stops calling methods
* of its channel control helper.
*/
destroy(): void;
/**
* Get the type name for this load balancer type. Must be constant across an
* entire load balancer implementation class and must match the name that the
* balancer implementation class was registered with.
*/
getTypeName(): string;
/**
* Replace the existing ChannelControlHelper with a new one
* @param channelControlHelper The new ChannelControlHelper to use from now on
*/
replaceChannelControlHelper(channelControlHelper: ChannelControlHelper): void;
}
export interface LoadBalancerConstructor {
new (channelControlHelper: ChannelControlHelper): LoadBalancer;
}
export declare function registerLoadBalancerType(typeName: string, loadBalancerType: LoadBalancerConstructor): void;
export declare function createLoadBalancer(typeName: string, channelControlHelper: ChannelControlHelper): LoadBalancer | null;
export declare function isLoadBalancerNameRegistered(typeName: string): boolean;
export declare function registerAll(): void;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const load_balancer_pick_first = require("./load-balancer-pick-first");
const registeredLoadBalancerTypes = {};
function registerLoadBalancerType(typeName, loadBalancerType) {
registeredLoadBalancerTypes[typeName] = loadBalancerType;
}
exports.registerLoadBalancerType = registerLoadBalancerType;
function createLoadBalancer(typeName, channelControlHelper) {
if (typeName in registeredLoadBalancerTypes) {
return new registeredLoadBalancerTypes[typeName](channelControlHelper);
}
else {
return null;
}
}
exports.createLoadBalancer = createLoadBalancer;
function isLoadBalancerNameRegistered(typeName) {
return typeName in registeredLoadBalancerTypes;
}
exports.isLoadBalancerNameRegistered = isLoadBalancerNameRegistered;
function registerAll() {
load_balancer_pick_first.setup();
}
exports.registerAll = registerAll;
//# sourceMappingURL=load-balancer.js.map
\ No newline at end of file
export interface RoundRobinConfig {
}
export interface XdsConfig {
balancerName: string;
childPolicy: LoadBalancingConfig[];
fallbackPolicy: LoadBalancingConfig[];
}
export interface GrpcLbConfig {
childPolicy: LoadBalancingConfig[];
}
export interface LoadBalancingConfig {
round_robin?: RoundRobinConfig;
xds?: XdsConfig;
grpclb?: GrpcLbConfig;
}
export declare function validateConfig(obj: any): LoadBalancingConfig;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
/* In these functions we assume the input came from a JSON object. Therefore we
* expect that the prototype is uninteresting and that `in` can be used
* effectively */
function validateXdsConfig(xds) {
if (!('balancerName' in xds) || typeof xds.balancerName !== 'string') {
throw new Error('Invalid xds config: invalid balancerName');
}
const xdsConfig = {
balancerName: xds.balancerName,
childPolicy: [],
fallbackPolicy: [],
};
if ('childPolicy' in xds) {
if (!Array.isArray(xds.childPolicy)) {
throw new Error('Invalid xds config: invalid childPolicy');
}
for (const policy of xds.childPolicy) {
xdsConfig.childPolicy.push(validateConfig(policy));
}
}
if ('fallbackPolicy' in xds) {
if (!Array.isArray(xds.fallbackPolicy)) {
throw new Error('Invalid xds config: invalid fallbackPolicy');
}
for (const policy of xds.fallbackPolicy) {
xdsConfig.fallbackPolicy.push(validateConfig(policy));
}
}
return xdsConfig;
}
function validateGrpcLbConfig(grpclb) {
const grpcLbConfig = {
childPolicy: [],
};
if ('childPolicy' in grpclb) {
if (!Array.isArray(grpclb.childPolicy)) {
throw new Error('Invalid xds config: invalid childPolicy');
}
for (const policy of grpclb.childPolicy) {
grpcLbConfig.childPolicy.push(validateConfig(policy));
}
}
return grpcLbConfig;
}
function validateConfig(obj) {
if ('round_robin' in obj) {
if ('xds' in obj || 'grpclb' in obj) {
throw new Error('Multiple load balancing policies configured');
}
if (obj['round_robin'] instanceof Object) {
return { round_robin: {} };
}
}
if ('xds' in obj) {
if ('grpclb' in obj) {
throw new Error('Multiple load balancing policies configured');
}
return { xds: validateXdsConfig(obj.xds) };
}
if ('grpclb' in obj) {
return { grpclb: validateGrpcLbConfig(obj.grpclb) };
}
throw new Error('No recognized load balancing policy configured');
}
exports.validateConfig = validateConfig;
//# sourceMappingURL=load-balancing-config.js.map
\ No newline at end of file
/// <reference types="node" />
import { LogVerbosity } from './constants';
export declare const getLogger: () => Partial<Console>;
export declare const setLogger: (logger: Partial<Console>) => void;
export declare const setLoggerVerbosity: (verbosity: LogVerbosity) => void;
export declare const log: (severity: LogVerbosity, ...args: any[]) => void;
export declare function trace(severity: LogVerbosity, tracer: string, text: string): void;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
let _logger = console;
let _logVerbosity = constants_1.LogVerbosity.ERROR;
if (process.env.GRPC_VERBOSITY) {
switch (process.env.GRPC_VERBOSITY) {
case 'DEBUG':
_logVerbosity = constants_1.LogVerbosity.DEBUG;
break;
case 'INFO':
_logVerbosity = constants_1.LogVerbosity.INFO;
break;
case 'ERROR':
_logVerbosity = constants_1.LogVerbosity.ERROR;
break;
default:
// Ignore any other values
}
}
exports.getLogger = () => {
return _logger;
};
exports.setLogger = (logger) => {
_logger = logger;
};
exports.setLoggerVerbosity = (verbosity) => {
_logVerbosity = verbosity;
};
// tslint:disable-next-line no-any
exports.log = (severity, ...args) => {
if (severity >= _logVerbosity && typeof _logger.error === 'function') {
_logger.error(...args);
}
};
const enabledTracers = process.env.GRPC_TRACE ? process.env.GRPC_TRACE.split(',') : [];
const allEnabled = enabledTracers.includes('all');
function trace(severity, tracer, text) {
if (allEnabled || enabledTracers.includes(tracer)) {
exports.log(severity, (new Date().toISOString() + ' | ' + tracer + ' | ' + text));
}
}
exports.trace = trace;
//# sourceMappingURL=logging.js.map
\ No newline at end of file
/// <reference types="node" />
import { ChannelCredentials } from './channel-credentials';
import { ChannelOptions } from './channel-options';
import { Client } from './client';
export interface Serialize<T> {
(value: T): Buffer;
}
export interface Deserialize<T> {
(bytes: Buffer): T;
}
export interface MethodDefinition<RequestType, ResponseType> {
path: string;
requestStream: boolean;
responseStream: boolean;
requestSerialize: Serialize<RequestType>;
responseSerialize: Serialize<ResponseType>;
requestDeserialize: Deserialize<RequestType>;
responseDeserialize: Deserialize<ResponseType>;
originalName?: string;
}
export interface ServiceDefinition {
[index: string]: MethodDefinition<any, any>;
}
export interface ProtobufTypeDefinition {
format: string;
type: object;
fileDescriptorProtos: Buffer[];
}
export interface PackageDefinition {
[index: string]: ServiceDefinition | ProtobufTypeDefinition;
}
export interface ServiceClient extends Client {
[methodName: string]: Function;
}
export interface ServiceClientConstructor {
new (address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): ServiceClient;
service: ServiceDefinition;
}
/**
* Creates a constructor for a client with the given methods, as specified in
* the methods argument. The resulting class will have an instance method for
* each method in the service, which is a partial application of one of the
* [Client]{@link grpc.Client} request methods, depending on `requestSerialize`
* and `responseSerialize`, with the `method`, `serialize`, and `deserialize`
* arguments predefined.
* @param methods An object mapping method names to
* method attributes
* @param serviceName The fully qualified name of the service
* @param classOptions An options object.
* @return New client constructor, which is a subclass of
* {@link grpc.Client}, and has the same arguments as that constructor.
*/
export declare function makeClientConstructor(methods: ServiceDefinition, serviceName: string, classOptions?: {}): ServiceClientConstructor;
export interface GrpcObject {
[index: string]: GrpcObject | ServiceClientConstructor | ProtobufTypeDefinition;
}
/**
* Load a gRPC package definition as a gRPC object hierarchy.
* @param packageDef The package definition object.
* @return The resulting gRPC object.
*/
export declare function loadPackageDefinition(packageDef: PackageDefinition): GrpcObject;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("./client");
/**
* Map with short names for each of the requester maker functions. Used in
* makeClientConstructor
* @private
*/
const requesterFuncs = {
unary: client_1.Client.prototype.makeUnaryRequest,
server_stream: client_1.Client.prototype.makeServerStreamRequest,
client_stream: client_1.Client.prototype.makeClientStreamRequest,
bidi: client_1.Client.prototype.makeBidiStreamRequest,
};
/**
* Creates a constructor for a client with the given methods, as specified in
* the methods argument. The resulting class will have an instance method for
* each method in the service, which is a partial application of one of the
* [Client]{@link grpc.Client} request methods, depending on `requestSerialize`
* and `responseSerialize`, with the `method`, `serialize`, and `deserialize`
* arguments predefined.
* @param methods An object mapping method names to
* method attributes
* @param serviceName The fully qualified name of the service
* @param classOptions An options object.
* @return New client constructor, which is a subclass of
* {@link grpc.Client}, and has the same arguments as that constructor.
*/
function makeClientConstructor(methods, serviceName, classOptions) {
if (!classOptions) {
classOptions = {};
}
class ServiceClientImpl extends client_1.Client {
}
Object.keys(methods).forEach(name => {
const attrs = methods[name];
let methodType;
// TODO(murgatroid99): Verify that we don't need this anymore
if (typeof name === 'string' && name.charAt(0) === '$') {
throw new Error('Method names cannot start with $');
}
if (attrs.requestStream) {
if (attrs.responseStream) {
methodType = 'bidi';
}
else {
methodType = 'client_stream';
}
}
else {
if (attrs.responseStream) {
methodType = 'server_stream';
}
else {
methodType = 'unary';
}
}
const serialize = attrs.requestSerialize;
const deserialize = attrs.responseDeserialize;
const methodFunc = partial(requesterFuncs[methodType], attrs.path, serialize, deserialize);
ServiceClientImpl.prototype[name] = methodFunc;
// Associate all provided attributes with the method
Object.assign(ServiceClientImpl.prototype[name], attrs);
if (attrs.originalName) {
ServiceClientImpl.prototype[attrs.originalName] =
ServiceClientImpl.prototype[name];
}
});
ServiceClientImpl.service = methods;
return ServiceClientImpl;
}
exports.makeClientConstructor = makeClientConstructor;
function partial(fn, path, serialize, deserialize) {
// tslint:disable-next-line:no-any
return function (...args) {
return fn.call(this, path, serialize, deserialize, ...args);
};
}
function isProtobufTypeDefinition(obj) {
return 'format' in obj;
}
/**
* Load a gRPC package definition as a gRPC object hierarchy.
* @param packageDef The package definition object.
* @return The resulting gRPC object.
*/
function loadPackageDefinition(packageDef) {
const result = {};
for (const serviceFqn in packageDef) {
if (packageDef.hasOwnProperty(serviceFqn)) {
const service = packageDef[serviceFqn];
const nameComponents = serviceFqn.split('.');
const serviceName = nameComponents[nameComponents.length - 1];
let current = result;
for (const packageName of nameComponents.slice(0, -1)) {
if (!current[packageName]) {
current[packageName] = {};
}
current = current[packageName];
}
if (isProtobufTypeDefinition(service)) {
current[serviceName] = service;
}
else {
current[serviceName] = makeClientConstructor(service, serviceName, {});
}
}
}
return result;
}
exports.loadPackageDefinition = loadPackageDefinition;
//# sourceMappingURL=make-client.js.map
\ No newline at end of file
import { Call } from './call-stream';
import { StatusObject } from './call-stream';
import { Channel } from './channel';
import { BaseFilter, Filter, FilterFactory } from './filter';
export declare class MetadataStatusFilter extends BaseFilter implements Filter {
receiveTrailers(status: Promise<StatusObject>): Promise<StatusObject>;
}
export declare class MetadataStatusFilterFactory implements FilterFactory<MetadataStatusFilter> {
private readonly channel;
constructor(channel: Channel);
createFilter(callStream: Call): MetadataStatusFilter;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
const filter_1 = require("./filter");
class MetadataStatusFilter extends filter_1.BaseFilter {
async receiveTrailers(status) {
// tslint:disable-next-line:prefer-const
let { code, details, metadata } = await status;
if (code !== constants_1.Status.UNKNOWN) {
// we already have a known status, so don't assign a new one.
return { code, details, metadata };
}
const metadataMap = metadata.getMap();
if (typeof metadataMap['grpc-status'] === 'string') {
const receivedCode = Number(metadataMap['grpc-status']);
if (receivedCode in constants_1.Status) {
code = receivedCode;
}
metadata.remove('grpc-status');
}
if (typeof metadataMap['grpc-message'] === 'string') {
details = decodeURI(metadataMap['grpc-message']);
metadata.remove('grpc-message');
}
return { code, details, metadata };
}
}
exports.MetadataStatusFilter = MetadataStatusFilter;
class MetadataStatusFilterFactory {
constructor(channel) {
this.channel = channel;
}
createFilter(callStream) {
return new MetadataStatusFilter();
}
}
exports.MetadataStatusFilterFactory = MetadataStatusFilterFactory;
//# sourceMappingURL=metadata-status-filter.js.map
\ No newline at end of file
/// <reference types="node" />
import * as http2 from 'http2';
export declare type MetadataValue = string | Buffer;
export declare type MetadataObject = Map<string, MetadataValue[]>;
export interface MetadataOptions {
idempotentRequest?: boolean;
waitForReady?: boolean;
cacheableRequest?: boolean;
corked?: boolean;
}
/**
* A class for storing metadata. Keys are normalized to lowercase ASCII.
*/
export declare class Metadata {
protected internalRepr: MetadataObject;
private options;
constructor(options?: MetadataOptions);
/**
* Sets the given value for the given key by replacing any other values
* associated with that key. Normalizes the key.
* @param key The key to whose value should be set.
* @param value The value to set. Must be a buffer if and only
* if the normalized key ends with '-bin'.
*/
set(key: string, value: MetadataValue): void;
/**
* Adds the given value for the given key by appending to a list of previous
* values associated with that key. Normalizes the key.
* @param key The key for which a new value should be appended.
* @param value The value to add. Must be a buffer if and only
* if the normalized key ends with '-bin'.
*/
add(key: string, value: MetadataValue): void;
/**
* Removes the given key and any associated values. Normalizes the key.
* @param key The key whose values should be removed.
*/
remove(key: string): void;
/**
* Gets a list of all values associated with the key. Normalizes the key.
* @param key The key whose value should be retrieved.
* @return A list of values associated with the given key.
*/
get(key: string): MetadataValue[];
/**
* Gets a plain object mapping each key to the first value associated with it.
* This reflects the most common way that people will want to see metadata.
* @return A key/value mapping of the metadata.
*/
getMap(): {
[key: string]: MetadataValue;
};
/**
* Clones the metadata object.
* @return The newly cloned object.
*/
clone(): Metadata;
/**
* Merges all key-value pairs from a given Metadata object into this one.
* If both this object and the given object have values in the same key,
* values from the other Metadata object will be appended to this object's
* values.
* @param other A Metadata object.
*/
merge(other: Metadata): void;
setOptions(options: MetadataOptions): void;
getOptions(): MetadataOptions;
/**
* Creates an OutgoingHttpHeaders object that can be used with the http2 API.
*/
toHttp2Headers(): http2.OutgoingHttpHeaders;
private _getCoreRepresentation;
/**
* Returns a new Metadata object based fields in a given IncomingHttpHeaders
* object.
* @param headers An IncomingHttpHeaders object.
*/
static fromHttp2Headers(headers: http2.IncomingHttpHeaders): Metadata;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const LEGAL_KEY_REGEX = /^[0-9a-z_.-]+$/;
const LEGAL_NON_BINARY_VALUE_REGEX = /^[ -~]*$/;
function isLegalKey(key) {
return LEGAL_KEY_REGEX.test(key);
}
function isLegalNonBinaryValue(value) {
return LEGAL_NON_BINARY_VALUE_REGEX.test(value);
}
function isBinaryKey(key) {
return key.endsWith('-bin');
}
function normalizeKey(key) {
return key.toLowerCase();
}
function validate(key, value) {
if (!isLegalKey(key)) {
throw new Error('Metadata key "' + key + '" contains illegal characters');
}
if (value != null) {
if (isBinaryKey(key)) {
if (!(value instanceof Buffer)) {
throw new Error("keys that end with '-bin' must have Buffer values");
}
}
else {
if (value instanceof Buffer) {
throw new Error("keys that don't end with '-bin' must have String values");
}
if (!isLegalNonBinaryValue(value)) {
throw new Error('Metadata string value "' + value + '" contains illegal characters');
}
}
}
}
/**
* A class for storing metadata. Keys are normalized to lowercase ASCII.
*/
class Metadata {
constructor(options) {
this.internalRepr = new Map();
if (options === undefined) {
this.options = {};
}
else {
this.options = options;
}
}
/**
* Sets the given value for the given key by replacing any other values
* associated with that key. Normalizes the key.
* @param key The key to whose value should be set.
* @param value The value to set. Must be a buffer if and only
* if the normalized key ends with '-bin'.
*/
set(key, value) {
key = normalizeKey(key);
validate(key, value);
this.internalRepr.set(key, [value]);
}
/**
* Adds the given value for the given key by appending to a list of previous
* values associated with that key. Normalizes the key.
* @param key The key for which a new value should be appended.
* @param value The value to add. Must be a buffer if and only
* if the normalized key ends with '-bin'.
*/
add(key, value) {
key = normalizeKey(key);
validate(key, value);
const existingValue = this.internalRepr.get(key);
if (existingValue === undefined) {
this.internalRepr.set(key, [value]);
}
else {
existingValue.push(value);
}
}
/**
* Removes the given key and any associated values. Normalizes the key.
* @param key The key whose values should be removed.
*/
remove(key) {
key = normalizeKey(key);
validate(key);
this.internalRepr.delete(key);
}
/**
* Gets a list of all values associated with the key. Normalizes the key.
* @param key The key whose value should be retrieved.
* @return A list of values associated with the given key.
*/
get(key) {
key = normalizeKey(key);
validate(key);
return this.internalRepr.get(key) || [];
}
/**
* Gets a plain object mapping each key to the first value associated with it.
* This reflects the most common way that people will want to see metadata.
* @return A key/value mapping of the metadata.
*/
getMap() {
const result = {};
this.internalRepr.forEach((values, key) => {
if (values.length > 0) {
const v = values[0];
result[key] = v instanceof Buffer ? v.slice() : v;
}
});
return result;
}
/**
* Clones the metadata object.
* @return The newly cloned object.
*/
clone() {
const newMetadata = new Metadata();
const newInternalRepr = newMetadata.internalRepr;
this.internalRepr.forEach((value, key) => {
const clonedValue = value.map(v => {
if (v instanceof Buffer) {
return Buffer.from(v);
}
else {
return v;
}
});
newInternalRepr.set(key, clonedValue);
});
return newMetadata;
}
/**
* Merges all key-value pairs from a given Metadata object into this one.
* If both this object and the given object have values in the same key,
* values from the other Metadata object will be appended to this object's
* values.
* @param other A Metadata object.
*/
merge(other) {
other.internalRepr.forEach((values, key) => {
const mergedValue = (this.internalRepr.get(key) || []).concat(values);
this.internalRepr.set(key, mergedValue);
});
}
setOptions(options) {
this.options = options;
}
getOptions() {
return this.options;
}
/**
* Creates an OutgoingHttpHeaders object that can be used with the http2 API.
*/
toHttp2Headers() {
// NOTE: Node <8.9 formats http2 headers incorrectly.
const result = {};
this.internalRepr.forEach((values, key) => {
// We assume that the user's interaction with this object is limited to
// through its public API (i.e. keys and values are already validated).
result[key] = values.map(value => {
if (value instanceof Buffer) {
return value.toString('base64');
}
else {
return value;
}
});
});
return result;
}
// For compatibility with the other Metadata implementation
_getCoreRepresentation() {
return this.internalRepr;
}
/**
* Returns a new Metadata object based fields in a given IncomingHttpHeaders
* object.
* @param headers An IncomingHttpHeaders object.
*/
static fromHttp2Headers(headers) {
const result = new Metadata();
Object.keys(headers).forEach(key => {
// Reserved headers (beginning with `:`) are not valid keys.
if (key.charAt(0) === ':') {
return;
}
const values = headers[key];
try {
if (isBinaryKey(key)) {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, Buffer.from(value, 'base64'));
});
}
else if (values !== undefined) {
values.split(',').forEach(v => {
result.add(key, Buffer.from(v.trim(), 'base64'));
});
}
}
else {
if (Array.isArray(values)) {
values.forEach(value => {
result.add(key, value);
});
}
else if (values !== undefined) {
values.split(',').forEach(v => result.add(key, v.trim()));
}
}
}
catch (error) {
error.message = `Failed to add metadata entry ${key}: ${values}. ${error.message}`;
process.emitWarning(error);
}
});
return result;
}
}
exports.Metadata = Metadata;
//# sourceMappingURL=metadata.js.map
\ No newline at end of file
/// <reference types="node" />
import { Duplex, Readable, Writable } from 'stream';
import { EmitterAugmentation1 } from './events';
export declare type WriteCallback = (error: Error | null | undefined) => void;
export interface IntermediateObjectReadable<T> extends Readable {
read(size?: number): any & T;
}
export declare type ObjectReadable<T> = {
read(size?: number): T;
} & EmitterAugmentation1<'data', T> & IntermediateObjectReadable<T>;
export interface IntermediateObjectWritable<T> extends Writable {
_write(chunk: any & T, encoding: string, callback: Function): void;
write(chunk: any & T, cb?: WriteCallback): boolean;
write(chunk: any & T, encoding?: any, cb?: WriteCallback): boolean;
setDefaultEncoding(encoding: string): this;
end(): void;
end(chunk: any & T, cb?: Function): void;
end(chunk: any & T, encoding?: any, cb?: Function): void;
}
export interface ObjectWritable<T> extends IntermediateObjectWritable<T> {
_write(chunk: T, encoding: string, callback: Function): void;
write(chunk: T, cb?: Function): boolean;
write(chunk: T, encoding?: any, cb?: Function): boolean;
setDefaultEncoding(encoding: string): this;
end(): void;
end(chunk: T, cb?: Function): void;
end(chunk: T, encoding?: any, cb?: Function): void;
}
export declare type ObjectDuplex<T, U> = {
read(size?: number): U;
_write(chunk: T, encoding: string, callback: Function): void;
write(chunk: T, cb?: Function): boolean;
write(chunk: T, encoding?: any, cb?: Function): boolean;
end(): void;
end(chunk: T, cb?: Function): void;
end(chunk: T, encoding?: any, cb?: Function): void;
} & Duplex & ObjectWritable<T> & ObjectReadable<U>;
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=object-stream.js.map
\ No newline at end of file
import { Subchannel } from './subchannel';
import { StatusObject } from './call-stream';
import { Metadata } from './metadata';
import { LoadBalancer } from './load-balancer';
export declare enum PickResultType {
COMPLETE = 0,
QUEUE = 1,
TRANSIENT_FAILURE = 2
}
export interface PickResult {
pickResultType: PickResultType;
/**
* The subchannel to use as the transport for the call. Only meaningful if
* `pickResultType` is COMPLETE. If null, indicates that the call should be
* dropped.
*/
subchannel: Subchannel | null;
/**
* The status object to end the call with. Populated if and only if
* `pickResultType` is TRANSIENT_FAILURE.
*/
status: StatusObject | null;
}
export interface CompletePickResult extends PickResult {
pickResultType: PickResultType.COMPLETE;
subchannel: Subchannel | null;
status: null;
}
export interface QueuePickResult extends PickResult {
pickResultType: PickResultType.QUEUE;
subchannel: null;
status: null;
}
export interface TransientFailurePickResult extends PickResult {
pickResultType: PickResultType.TRANSIENT_FAILURE;
subchannel: null;
status: StatusObject;
}
export interface PickArgs {
metadata: Metadata;
}
/**
* A proxy object representing the momentary state of a load balancer. Picks
* subchannels or returns other information based on that state. Should be
* replaced every time the load balancer changes state.
*/
export interface Picker {
pick(pickArgs: PickArgs): PickResult;
}
/**
* A standard picker representing a load balancer in the TRANSIENT_FAILURE
* state. Always responds to every pick request with an UNAVAILABLE status.
*/
export declare class UnavailablePicker implements Picker {
private status;
constructor(status?: StatusObject);
pick(pickArgs: PickArgs): TransientFailurePickResult;
}
/**
* A standard picker representing a load balancer in the IDLE or CONNECTING
* state. Always responds to every pick request with a QUEUE pick result
* indicating that the pick should be tried again with the next `Picker`. Also
* reports back to the load balancer that a connection should be established
* once any pick is attempted.
*/
export declare class QueuePicker {
private loadBalancer;
private calledExitIdle;
constructor(loadBalancer: LoadBalancer);
pick(pickArgs: PickArgs): QueuePickResult;
}
"use strict";
/*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const metadata_1 = require("./metadata");
const constants_1 = require("./constants");
var PickResultType;
(function (PickResultType) {
PickResultType[PickResultType["COMPLETE"] = 0] = "COMPLETE";
PickResultType[PickResultType["QUEUE"] = 1] = "QUEUE";
PickResultType[PickResultType["TRANSIENT_FAILURE"] = 2] = "TRANSIENT_FAILURE";
})(PickResultType = exports.PickResultType || (exports.PickResultType = {}));
/**
* A standard picker representing a load balancer in the TRANSIENT_FAILURE
* state. Always responds to every pick request with an UNAVAILABLE status.
*/
class UnavailablePicker {
constructor(status) {
if (status !== undefined) {
this.status = status;
}
else {
this.status = {
code: constants_1.Status.UNAVAILABLE,
details: 'No connection established',
metadata: new metadata_1.Metadata(),
};
}
}
pick(pickArgs) {
return {
pickResultType: PickResultType.TRANSIENT_FAILURE,
subchannel: null,
status: this.status,
};
}
}
exports.UnavailablePicker = UnavailablePicker;
/**
* A standard picker representing a load balancer in the IDLE or CONNECTING
* state. Always responds to every pick request with a QUEUE pick result
* indicating that the pick should be tried again with the next `Picker`. Also
* reports back to the load balancer that a connection should be established
* once any pick is attempted.
*/
class QueuePicker {
// Constructed with a load balancer. Calls exitIdle on it the first time pick is called
constructor(loadBalancer) {
this.loadBalancer = loadBalancer;
this.calledExitIdle = false;
}
pick(pickArgs) {
if (!this.calledExitIdle) {
process.nextTick(() => {
this.loadBalancer.exitIdle();
});
this.calledExitIdle = true;
}
return {
pickResultType: PickResultType.QUEUE,
subchannel: null,
status: null,
};
}
}
exports.QueuePicker = QueuePicker;
//# sourceMappingURL=picker.js.map
\ No newline at end of file
/**
* Set up the DNS resolver class by registering it as the handler for the
* "dns:" prefix and as the default resolver.
*/
export declare function setup(): void;
This diff is collapsed. Click to expand it.
export declare function setup(): void;
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.