UNPKG

2.86 kBTypeScriptView Raw
1/// <reference types="node" />
2import { CallCredentials } from "./call-credentials";
3import { Status } from "./constants";
4import { Deadline } from "./deadline";
5import { Metadata } from "./metadata";
6import { CallConfig } from "./resolver";
7import { Call, InterceptingListener, MessageContext } from "./call-interface";
8import { InternalChannel } from "./internal-channel";
9export declare class RetryThrottler {
10 private readonly maxTokens;
11 private readonly tokenRatio;
12 private tokens;
13 constructor(maxTokens: number, tokenRatio: number, previousRetryThrottler?: RetryThrottler);
14 addCallSucceeded(): void;
15 addCallFailed(): void;
16 canRetryCall(): boolean;
17}
18export declare class MessageBufferTracker {
19 private totalLimit;
20 private limitPerCall;
21 private totalAllocated;
22 private allocatedPerCall;
23 constructor(totalLimit: number, limitPerCall: number);
24 allocate(size: number, callId: number): boolean;
25 free(size: number, callId: number): void;
26 freeAll(callId: number): void;
27}
28export declare class RetryingCall implements Call {
29 private readonly channel;
30 private readonly callConfig;
31 private readonly methodName;
32 private readonly host;
33 private readonly credentials;
34 private readonly deadline;
35 private readonly callNumber;
36 private readonly bufferTracker;
37 private readonly retryThrottler?;
38 private state;
39 private listener;
40 private initialMetadata;
41 private underlyingCalls;
42 private writeBuffer;
43 private transparentRetryUsed;
44 /**
45 * Number of attempts so far
46 */
47 private attempts;
48 private hedgingTimer;
49 private committedCallIndex;
50 private initialRetryBackoffSec;
51 private nextRetryBackoffSec;
52 constructor(channel: InternalChannel, callConfig: CallConfig, methodName: string, host: string, credentials: CallCredentials, deadline: Deadline, callNumber: number, bufferTracker: MessageBufferTracker, retryThrottler?: RetryThrottler | undefined);
53 getCallNumber(): number;
54 private trace;
55 private reportStatus;
56 cancelWithStatus(status: Status, details: string): void;
57 getPeer(): string;
58 private commitCall;
59 private commitCallWithMostMessages;
60 private isStatusCodeInList;
61 private getNextRetryBackoffMs;
62 private maybeRetryCall;
63 private countActiveCalls;
64 private handleProcessedStatus;
65 private getPushback;
66 private handleChildStatus;
67 private maybeStartHedgingAttempt;
68 private maybeStartHedgingTimer;
69 private startNewAttempt;
70 start(metadata: Metadata, listener: InterceptingListener): void;
71 private sendNextChildMessage;
72 sendMessageWithContext(context: MessageContext, message: Buffer): void;
73 startRead(): void;
74 halfClose(): void;
75 setCredentials(newCredentials: CallCredentials): void;
76 getMethod(): string;
77 getHost(): string;
78}