44 * This source code is licensed under the MIT license found in the
55 * LICENSE file in the root directory of this source tree.
66 *
7- * @format
87 * @flow
8+ * @format
9+ * @oncall react_native
910 */
1011
1112import type { HttpsProxyAgentOptions } from 'https-proxy-agent' ;
@@ -78,19 +79,19 @@ export default class HttpStore<T> {
7879 static HttpError : typeof HttpError = HttpError ;
7980 static NetworkError : typeof NetworkError = NetworkError ;
8081
81- _getEndpoint : Endpoint ;
82- _setEndpoint : Endpoint ;
82+ #getEndpoint : Endpoint ;
83+ #setEndpoint : Endpoint ;
8384
8485 constructor ( options : Options ) {
85- this . _getEndpoint = this . createEndpointConfig (
86+ this . #getEndpoint = this . # createEndpointConfig(
8687 options . getOptions != null ? options . getOptions : options ,
8788 ) ;
88- this . _setEndpoint = this . createEndpointConfig (
89+ this . #setEndpoint = this . # createEndpointConfig(
8990 options . setOptions != null ? options . setOptions : options ,
9091 ) ;
9192 }
9293
93- createEndpointConfig(options: EndpointOptions): Endpoint {
94+ # createEndpointConfig(options: EndpointOptions): Endpoint {
9495 const agentConfig : http$agentOptions & HttpsProxyAgentOptions = {
9596 family : options . family ,
9697 keepAlive : true ,
@@ -151,32 +152,32 @@ export default class HttpStore<T> {
151152 }
152153
153154 get ( key : Buffer ) : Promise < ?T > {
154- return this . #withRetries( ( ) => this . #getOnce( key ) , this . _getEndpoint ) ;
155+ return this . #withRetries( ( ) => this . #getOnce( key ) , this . #getEndpoint ) ;
155156 }
156157
157158 #getOnce(key: Buffer): Promise< ?T > {
158159 return new Promise ( ( resolve , reject ) => {
159- let searchParamsString = this . _getEndpoint . params . toString ( ) ;
160+ let searchParamsString = this . #getEndpoint . params . toString ( ) ;
160161 if ( searchParamsString != '' ) {
161162 searchParamsString = '?' + searchParamsString ;
162163 }
163164 const options = {
164- agent : this . _getEndpoint . agent ,
165- headers : this . _getEndpoint . headers ,
166- host : this . _getEndpoint . host ,
165+ agent : this . #getEndpoint . agent ,
166+ headers : this . #getEndpoint . headers ,
167+ host : this . #getEndpoint . host ,
167168 method : 'GET' ,
168- path : `${ this . _getEndpoint . path } /${ key . toString (
169+ path : `${ this . #getEndpoint . path } /${ key . toString (
169170 'hex' ,
170171 ) } ${ searchParamsString } `,
171- port : this . _getEndpoint . port ,
172- timeout : this . _getEndpoint . timeout ,
172+ port : this . #getEndpoint . port ,
173+ timeout : this . #getEndpoint . timeout ,
173174 } ;
174175
175176 // $FlowFixMe[incompatible-type]
176177 /* $FlowFixMe[missing-local-annot](>=0.101.0 site=react_native_fb) This comment suppresses an
177178 * error found when Flow v0.101 was deployed. To see the error, delete
178179 * this comment and run Flow. */
179- const req = this . _getEndpoint . module . request ( options , res => {
180+ const req = this . #getEndpoint . module . request ( options , res => {
180181 const code = res . statusCode ;
181182 const data = [ ] ;
182183
@@ -187,9 +188,9 @@ export default class HttpStore<T> {
187188 return ;
188189 } else if (
189190 code !== 200 &&
190- ! this . _getEndpoint . additionalSuccessStatuses . has ( code )
191+ ! this . #getEndpoint . additionalSuccessStatuses . has ( code )
191192 ) {
192- if ( this . _getEndpoint . debug ) {
193+ if ( this . #getEndpoint . debug ) {
193194 res . on ( 'data' , chunk => {
194195 data . push ( chunk ) ;
195196 } ) ;
@@ -275,43 +276,43 @@ export default class HttpStore<T> {
275276 set(key: Buffer, value: T): Promise< void > {
276277 return this . #withRetries(
277278 ( ) => this . #setOnce( key , value ) ,
278- this . _setEndpoint ,
279+ this . #setEndpoint ,
279280 ) ;
280281 }
281282
282283 #setOnce(key: Buffer, value: T): Promise< void > {
283284 return new Promise ( ( resolve , reject ) => {
284285 const gzip = zlib . createGzip ( ZLIB_OPTIONS ) ;
285286
286- let searchParamsString = this . _setEndpoint . params . toString ( ) ;
287+ let searchParamsString = this . #setEndpoint . params . toString ( ) ;
287288 if ( searchParamsString != '' ) {
288289 searchParamsString = '?' + searchParamsString ;
289290 }
290291
291292 const options = {
292- agent : this . _setEndpoint . agent ,
293- headers : this . _setEndpoint . headers ,
294- host : this . _setEndpoint . host ,
293+ agent : this . #setEndpoint . agent ,
294+ headers : this . #setEndpoint . headers ,
295+ host : this . #setEndpoint . host ,
295296 method : 'PUT' ,
296- path : `${ this . _setEndpoint . path } /${ key . toString (
297+ path : `${ this . #setEndpoint . path } /${ key . toString (
297298 'hex' ,
298299 ) } ${ searchParamsString } `,
299- port : this . _setEndpoint . port ,
300- timeout : this . _setEndpoint . timeout ,
300+ port : this . #setEndpoint . port ,
301+ timeout : this . #setEndpoint . timeout ,
301302 } ;
302303
303304 // $FlowFixMe[incompatible-type]
304305 /* $FlowFixMe[missing-local-annot](>=0.101.0 site=react_native_fb) This comment suppresses an
305306 * error found when Flow v0.101 was deployed. To see the error, delete
306307 * this comment and run Flow. */
307- const req = this . _setEndpoint . module . request ( options , res => {
308+ const req = this . #setEndpoint . module . request ( options , res => {
308309 const code = res . statusCode ;
309310
310311 if (
311312 ( code < 200 || code > 299 ) &&
312- ! this . _setEndpoint . additionalSuccessStatuses . has ( code )
313+ ! this . #setEndpoint . additionalSuccessStatuses . has ( code )
313314 ) {
314- if ( this . _setEndpoint . debug ) {
315+ if ( this . #setEndpoint . debug ) {
315316 const data = [ ] ;
316317 res . on ( 'data' , chunk => {
317318 data . push ( chunk ) ;
@@ -395,13 +396,13 @@ export default class HttpStore<T> {
395396 return backOff(fn, {
396397 jitter : 'full' ,
397398 maxDelay : 30000 ,
398- numOfAttempts : this . _getEndpoint . maxAttempts || Number . POSITIVE_INFINITY ,
399+ numOfAttempts : this . #getEndpoint . maxAttempts || Number . POSITIVE_INFINITY ,
399400 retry : ( e : Error ) => {
400401 if ( e instanceof HttpError ) {
401- return this . _getEndpoint . retryStatuses . has ( e . code ) ;
402+ return this . #getEndpoint . retryStatuses . has ( e . code ) ;
402403 }
403404 return (
404- e instanceof NetworkError && this . _getEndpoint . retryNetworkErrors
405+ e instanceof NetworkError && this . #getEndpoint . retryNetworkErrors
405406 ) ;
406407 } ,
407408 } );
0 commit comments