1 |
|
2 |
|
3 |
|
4 | import { EventEmitter } from 'events';
|
5 | import { Duplex, Readable, Writable } from 'stream';
|
6 | import { StatusObject } from './call-interface';
|
7 | import { EmitterAugmentation1 } from './events';
|
8 | import { Metadata } from './metadata';
|
9 | import { ObjectReadable, ObjectWritable, WriteCallback } from './object-stream';
|
10 | import { InterceptingCallInterface } from './client-interceptors';
|
11 |
|
12 |
|
13 |
|
14 | export type ServiceError = StatusObject & Error;
|
15 |
|
16 |
|
17 |
|
18 | export type SurfaceCall = {
|
19 | call?: InterceptingCallInterface;
|
20 | cancel(): void;
|
21 | getPeer(): string;
|
22 | } & EmitterAugmentation1<'metadata', Metadata> & EmitterAugmentation1<'status', StatusObject> & EventEmitter;
|
23 |
|
24 |
|
25 |
|
26 | export type ClientUnaryCall = SurfaceCall;
|
27 |
|
28 |
|
29 |
|
30 | export type ClientReadableStream<ResponseType> = {
|
31 | deserialize: (chunk: Buffer) => ResponseType;
|
32 | } & SurfaceCall & ObjectReadable<ResponseType>;
|
33 |
|
34 |
|
35 |
|
36 | export type ClientWritableStream<RequestType> = {
|
37 | serialize: (value: RequestType) => Buffer;
|
38 | } & SurfaceCall & ObjectWritable<RequestType>;
|
39 |
|
40 |
|
41 |
|
42 | export type ClientDuplexStream<RequestType, ResponseType> = ClientWritableStream<RequestType> & ClientReadableStream<ResponseType>;
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | export declare function callErrorFromStatus(status: StatusObject, callerStack: string): ServiceError;
|
50 | export declare class ClientUnaryCallImpl extends EventEmitter implements ClientUnaryCall {
|
51 | call?: InterceptingCallInterface;
|
52 | constructor();
|
53 | cancel(): void;
|
54 | getPeer(): string;
|
55 | }
|
56 | export declare class ClientReadableStreamImpl<ResponseType> extends Readable implements ClientReadableStream<ResponseType> {
|
57 | readonly deserialize: (chunk: Buffer) => ResponseType;
|
58 | call?: InterceptingCallInterface;
|
59 | constructor(deserialize: (chunk: Buffer) => ResponseType);
|
60 | cancel(): void;
|
61 | getPeer(): string;
|
62 | _read(_size: number): void;
|
63 | }
|
64 | export declare class ClientWritableStreamImpl<RequestType> extends Writable implements ClientWritableStream<RequestType> {
|
65 | readonly serialize: (value: RequestType) => Buffer;
|
66 | call?: InterceptingCallInterface;
|
67 | constructor(serialize: (value: RequestType) => Buffer);
|
68 | cancel(): void;
|
69 | getPeer(): string;
|
70 | _write(chunk: RequestType, encoding: string, cb: WriteCallback): void;
|
71 | _final(cb: Function): void;
|
72 | }
|
73 | export declare class ClientDuplexStreamImpl<RequestType, ResponseType> extends Duplex implements ClientDuplexStream<RequestType, ResponseType> {
|
74 | readonly serialize: (value: RequestType) => Buffer;
|
75 | readonly deserialize: (chunk: Buffer) => ResponseType;
|
76 | call?: InterceptingCallInterface;
|
77 | constructor(serialize: (value: RequestType) => Buffer, deserialize: (chunk: Buffer) => ResponseType);
|
78 | cancel(): void;
|
79 | getPeer(): string;
|
80 | _read(_size: number): void;
|
81 | _write(chunk: RequestType, encoding: string, cb: WriteCallback): void;
|
82 | _final(cb: Function): void;
|
83 | }
|