김수민

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.

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