UNPKG

2.23 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as http2 from 'http2';
3import { Status } from './constants';
4import { SubchannelCallStatsTracker, Subchannel } from './subchannel';
5import { InterceptingListener, MessageContext, StatusObject } from './call-interface';
6export interface SubchannelCall {
7 cancelWithStatus(status: Status, details: string): void;
8 getPeer(): string;
9 sendMessageWithContext(context: MessageContext, message: Buffer): void;
10 startRead(): void;
11 halfClose(): void;
12 getCallNumber(): number;
13}
14export interface StatusObjectWithRstCode extends StatusObject {
15 rstCode?: number;
16}
17export interface SubchannelCallInterceptingListener extends InterceptingListener {
18 onReceiveStatus(status: StatusObjectWithRstCode): void;
19}
20export declare class Http2SubchannelCall implements SubchannelCall {
21 private readonly http2Stream;
22 private readonly callStatsTracker;
23 private readonly listener;
24 private readonly subchannel;
25 private readonly callId;
26 private decoder;
27 private isReadFilterPending;
28 private canPush;
29 /**
30 * Indicates that an 'end' event has come from the http2 stream, so there
31 * will be no more data events.
32 */
33 private readsClosed;
34 private statusOutput;
35 private unpushedReadMessages;
36 private mappedStatusCode;
37 private finalStatus;
38 private disconnectListener;
39 private internalError;
40 constructor(http2Stream: http2.ClientHttp2Stream, callStatsTracker: SubchannelCallStatsTracker, listener: SubchannelCallInterceptingListener, subchannel: Subchannel, callId: number);
41 private outputStatus;
42 private trace;
43 /**
44 * On first call, emits a 'status' event with the given StatusObject.
45 * Subsequent calls are no-ops.
46 * @param status The status of the call.
47 */
48 private endCall;
49 private maybeOutputStatus;
50 private push;
51 private tryPush;
52 private handleTrailers;
53 private destroyHttp2Stream;
54 cancelWithStatus(status: Status, details: string): void;
55 getStatus(): StatusObject | null;
56 getPeer(): string;
57 getCallNumber(): number;
58 startRead(): void;
59 sendMessageWithContext(context: MessageContext, message: Buffer): void;
60 halfClose(): void;
61}