1 |
|
2 | import { CallCredentials } from './call-credentials';
|
3 | import { Status } from './constants';
|
4 | import { Deadline } from './deadline';
|
5 | import { Metadata } from './metadata';
|
6 | import { ServerSurfaceCall } from './server-call';
|
7 | export interface CallStreamOptions {
|
8 | deadline: Deadline;
|
9 | flags: number;
|
10 | host: string;
|
11 | parentCall: ServerSurfaceCall | null;
|
12 | }
|
13 | export type PartialCallStreamOptions = Partial<CallStreamOptions>;
|
14 | export interface StatusObject {
|
15 | code: Status;
|
16 | details: string;
|
17 | metadata: Metadata;
|
18 | }
|
19 | export type PartialStatusObject = Pick<StatusObject, 'code' | 'details'> & {
|
20 | metadata?: Metadata | null | undefined;
|
21 | };
|
22 | export declare const enum WriteFlags {
|
23 | BufferHint = 1,
|
24 | NoCompress = 2,
|
25 | WriteThrough = 4
|
26 | }
|
27 | export interface WriteObject {
|
28 | message: Buffer;
|
29 | flags?: number;
|
30 | }
|
31 | export interface MetadataListener {
|
32 | (metadata: Metadata, next: (metadata: Metadata) => void): void;
|
33 | }
|
34 | export interface MessageListener {
|
35 | (message: any, next: (message: any) => void): void;
|
36 | }
|
37 | export interface StatusListener {
|
38 | (status: StatusObject, next: (status: StatusObject) => void): void;
|
39 | }
|
40 | export interface FullListener {
|
41 | onReceiveMetadata: MetadataListener;
|
42 | onReceiveMessage: MessageListener;
|
43 | onReceiveStatus: StatusListener;
|
44 | }
|
45 | export type Listener = Partial<FullListener>;
|
46 |
|
47 |
|
48 |
|
49 | export interface InterceptingListener {
|
50 | onReceiveMetadata(metadata: Metadata): void;
|
51 | onReceiveMessage(message: any): void;
|
52 | onReceiveStatus(status: StatusObject): void;
|
53 | }
|
54 | export declare function isInterceptingListener(listener: Listener | InterceptingListener): listener is InterceptingListener;
|
55 | export declare class InterceptingListenerImpl implements InterceptingListener {
|
56 | private listener;
|
57 | private nextListener;
|
58 | private processingMetadata;
|
59 | private hasPendingMessage;
|
60 | private pendingMessage;
|
61 | private processingMessage;
|
62 | private pendingStatus;
|
63 | constructor(listener: FullListener, nextListener: InterceptingListener);
|
64 | private processPendingMessage;
|
65 | private processPendingStatus;
|
66 | onReceiveMetadata(metadata: Metadata): void;
|
67 | onReceiveMessage(message: any): void;
|
68 | onReceiveStatus(status: StatusObject): void;
|
69 | }
|
70 | export interface WriteCallback {
|
71 | (error?: Error | null): void;
|
72 | }
|
73 | export interface MessageContext {
|
74 | callback?: WriteCallback;
|
75 | flags?: number;
|
76 | }
|
77 | export interface Call {
|
78 | cancelWithStatus(status: Status, details: string): void;
|
79 | getPeer(): string;
|
80 | start(metadata: Metadata, listener: InterceptingListener): void;
|
81 | sendMessageWithContext(context: MessageContext, message: Buffer): void;
|
82 | startRead(): void;
|
83 | halfClose(): void;
|
84 | getCallNumber(): number;
|
85 | setCredentials(credentials: CallCredentials): void;
|
86 | }
|
87 | export interface DeadlineInfoProvider {
|
88 | getDeadlineInfo(): string[];
|
89 | }
|