1 |
|
2 | import * as http2 from 'http2';
|
3 | import { CallCredentials } from './call-credentials';
|
4 | import { Status } from './constants';
|
5 | import { Filter, FilterFactory } from './filter';
|
6 | import { FilterStackFactory } from './filter-stack';
|
7 | import { Metadata } from './metadata';
|
8 | import { ChannelImplementation } from './channel';
|
9 | import { Subchannel } from './subchannel';
|
10 | import { ServerSurfaceCall } from './server-call';
|
11 | export declare type Deadline = Date | number;
|
12 | export interface CallStreamOptions {
|
13 | deadline: Deadline;
|
14 | flags: number;
|
15 | host: string;
|
16 | parentCall: ServerSurfaceCall | null;
|
17 | }
|
18 | export declare type PartialCallStreamOptions = Partial<CallStreamOptions>;
|
19 | export interface StatusObject {
|
20 | code: Status;
|
21 | details: string;
|
22 | metadata: Metadata;
|
23 | }
|
24 | export declare const enum WriteFlags {
|
25 | BufferHint = 1,
|
26 | NoCompress = 2,
|
27 | WriteThrough = 4
|
28 | }
|
29 | export interface WriteObject {
|
30 | message: Buffer;
|
31 | flags?: number;
|
32 | }
|
33 | export interface MetadataListener {
|
34 | (metadata: Metadata, next: (metadata: Metadata) => void): void;
|
35 | }
|
36 | export interface MessageListener {
|
37 | (message: any, next: (message: any) => void): void;
|
38 | }
|
39 | export interface StatusListener {
|
40 | (status: StatusObject, next: (status: StatusObject) => void): void;
|
41 | }
|
42 | export interface FullListener {
|
43 | onReceiveMetadata: MetadataListener;
|
44 | onReceiveMessage: MessageListener;
|
45 | onReceiveStatus: StatusListener;
|
46 | }
|
47 | export declare type Listener = Partial<FullListener>;
|
48 |
|
49 |
|
50 |
|
51 | export interface InterceptingListener {
|
52 | onReceiveMetadata(metadata: Metadata): void;
|
53 | onReceiveMessage(message: any): void;
|
54 | onReceiveStatus(status: StatusObject): void;
|
55 | }
|
56 | export declare function isInterceptingListener(listener: Listener | InterceptingListener): listener is InterceptingListener;
|
57 | export declare class InterceptingListenerImpl implements InterceptingListener {
|
58 | private listener;
|
59 | private nextListener;
|
60 | private processingMessage;
|
61 | private pendingStatus;
|
62 | constructor(listener: FullListener, nextListener: InterceptingListener);
|
63 | onReceiveMetadata(metadata: Metadata): void;
|
64 | onReceiveMessage(message: any): void;
|
65 | onReceiveStatus(status: StatusObject): void;
|
66 | }
|
67 | export interface WriteCallback {
|
68 | (error?: Error | null): void;
|
69 | }
|
70 | export interface MessageContext {
|
71 | callback?: WriteCallback;
|
72 | flags?: number;
|
73 | }
|
74 | export interface Call {
|
75 | cancelWithStatus(status: Status, details: string): void;
|
76 | getPeer(): string;
|
77 | start(metadata: Metadata, listener: InterceptingListener): void;
|
78 | sendMessageWithContext(context: MessageContext, message: Buffer): void;
|
79 | startRead(): void;
|
80 | halfClose(): void;
|
81 | getDeadline(): Deadline;
|
82 | getCredentials(): CallCredentials;
|
83 | setCredentials(credentials: CallCredentials): void;
|
84 | getMethod(): string;
|
85 | getHost(): string;
|
86 | }
|
87 | export declare class Http2CallStream implements Call {
|
88 | private readonly methodName;
|
89 | private readonly channel;
|
90 | private readonly options;
|
91 | private readonly channelCallCredentials;
|
92 | private readonly callNumber;
|
93 | credentials: CallCredentials;
|
94 | filterStack: Filter;
|
95 | private http2Stream;
|
96 | private pendingRead;
|
97 | private isWriteFilterPending;
|
98 | private pendingWrite;
|
99 | private pendingWriteCallback;
|
100 | private writesClosed;
|
101 | private decoder;
|
102 | private isReadFilterPending;
|
103 | private canPush;
|
104 | |
105 |
|
106 |
|
107 |
|
108 | private readsClosed;
|
109 | private statusOutput;
|
110 | private unpushedReadMessages;
|
111 | private unfilteredReadMessages;
|
112 | private mappedStatusCode;
|
113 | private finalStatus;
|
114 | private subchannel;
|
115 | private disconnectListener;
|
116 | private listener;
|
117 | private internalError;
|
118 | constructor(methodName: string, channel: ChannelImplementation, options: CallStreamOptions, filterStackFactory: FilterStackFactory, channelCallCredentials: CallCredentials, callNumber: number);
|
119 | private outputStatus;
|
120 | private trace;
|
121 | /**
|
122 | * On first call, emits a 'status' event with the given StatusObject.
|
123 | * Subsequent calls are no-ops.
|
124 | * @param status The status of the call.
|
125 | */
|
126 | private endCall;
|
127 | private maybeOutputStatus;
|
128 | private push;
|
129 | private handleFilterError;
|
130 | private handleFilteredRead;
|
131 | private filterReceivedMessage;
|
132 | private tryPush;
|
133 | private handleTrailers;
|
134 | attachHttp2Stream(stream: http2.ClientHttp2Stream, subchannel: Subchannel, extraFilterFactory?: FilterFactory<Filter>): void;
|
135 | start(metadata: Metadata, listener: InterceptingListener): void;
|
136 | private destroyHttp2Stream;
|
137 | cancelWithStatus(status: Status, details: string): void;
|
138 | getDeadline(): Deadline;
|
139 | getCredentials(): CallCredentials;
|
140 | setCredentials(credentials: CallCredentials): void;
|
141 | getStatus(): StatusObject | null;
|
142 | getPeer(): string;
|
143 | getMethod(): string;
|
144 | getHost(): string;
|
145 | startRead(): void;
|
146 | private maybeCloseWrites;
|
147 | sendMessageWithContext(context: MessageContext, message: Buffer): void;
|
148 | halfClose(): void;
|
149 | }
|