1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import {
|
19 | ClientDuplexStream,
|
20 | ClientReadableStream,
|
21 | ClientUnaryCall,
|
22 | ClientWritableStream,
|
23 | ServiceError,
|
24 | } from './call';
|
25 | import { CallCredentials, OAuth2Client } from './call-credentials';
|
26 | import { Deadline, StatusObject } from './call-stream';
|
27 | import { Channel, ChannelImplementation } from './channel';
|
28 | import { CompressionAlgorithms } from './compression-algorithms';
|
29 | import { ConnectivityState } from './connectivity-state';
|
30 | import { ChannelCredentials } from './channel-credentials';
|
31 | import {
|
32 | CallOptions,
|
33 | Client,
|
34 | ClientOptions,
|
35 | CallInvocationTransformer,
|
36 | CallProperties,
|
37 | UnaryCallback,
|
38 | } from './client';
|
39 | import { LogVerbosity, Status, Propagate } from './constants';
|
40 | import * as logging from './logging';
|
41 | import {
|
42 | Deserialize,
|
43 | loadPackageDefinition,
|
44 | makeClientConstructor,
|
45 | MethodDefinition,
|
46 | ProtobufTypeDefinition,
|
47 | Serialize,
|
48 | ServiceClientConstructor,
|
49 | ServiceDefinition,
|
50 | } from './make-client';
|
51 | import { Metadata, MetadataOptions, MetadataValue } from './metadata';
|
52 | import {
|
53 | Server,
|
54 | UntypedHandleCall,
|
55 | UntypedServiceImplementation,
|
56 | } from './server';
|
57 | import { KeyCertPair, ServerCredentials } from './server-credentials';
|
58 | import { StatusBuilder } from './status-builder';
|
59 | import {
|
60 | handleBidiStreamingCall,
|
61 | handleServerStreamingCall,
|
62 | handleClientStreamingCall,
|
63 | handleUnaryCall,
|
64 | sendUnaryData,
|
65 | ServerUnaryCall,
|
66 | ServerReadableStream,
|
67 | ServerWritableStream,
|
68 | ServerDuplexStream,
|
69 | ServerErrorResponse,
|
70 | } from './server-call';
|
71 |
|
72 | export { OAuth2Client };
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | export const credentials = {
|
78 | |
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | combineChannelCredentials: (
|
86 | channelCredentials: ChannelCredentials,
|
87 | ...callCredentials: CallCredentials[]
|
88 | ): ChannelCredentials => {
|
89 | return callCredentials.reduce(
|
90 | (acc, other) => acc.compose(other),
|
91 | channelCredentials
|
92 | );
|
93 | },
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | combineCallCredentials: (
|
103 | first: CallCredentials,
|
104 | ...additional: CallCredentials[]
|
105 | ): CallCredentials => {
|
106 | return additional.reduce((acc, other) => acc.compose(other), first);
|
107 | },
|
108 |
|
109 |
|
110 | createInsecure: ChannelCredentials.createInsecure,
|
111 | createSsl: ChannelCredentials.createSsl,
|
112 | createFromSecureContext: ChannelCredentials.createFromSecureContext,
|
113 |
|
114 |
|
115 | createFromMetadataGenerator: CallCredentials.createFromMetadataGenerator,
|
116 | createFromGoogleCredential: CallCredentials.createFromGoogleCredential,
|
117 | createEmpty: CallCredentials.createEmpty,
|
118 | };
|
119 |
|
120 |
|
121 |
|
122 | export { Metadata, MetadataOptions, MetadataValue };
|
123 |
|
124 |
|
125 |
|
126 | export {
|
127 | LogVerbosity as logVerbosity,
|
128 | Status as status,
|
129 | ConnectivityState as connectivityState,
|
130 | Propagate as propagate,
|
131 | CompressionAlgorithms as compressionAlgorithms
|
132 |
|
133 | };
|
134 |
|
135 |
|
136 |
|
137 | export {
|
138 | Client,
|
139 | ClientOptions,
|
140 | loadPackageDefinition,
|
141 | makeClientConstructor,
|
142 | makeClientConstructor as makeGenericClientConstructor,
|
143 | CallProperties,
|
144 | CallInvocationTransformer,
|
145 | ChannelImplementation as Channel,
|
146 | Channel as ChannelInterface,
|
147 | UnaryCallback as requestCallback,
|
148 | };
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | export const closeClient = (client: Client) => client.close();
|
155 |
|
156 | export const waitForClientReady = (
|
157 | client: Client,
|
158 | deadline: Date | number,
|
159 | callback: (error?: Error) => void
|
160 | ) => client.waitForReady(deadline, callback);
|
161 |
|
162 |
|
163 |
|
164 | export {
|
165 | sendUnaryData,
|
166 | ChannelCredentials,
|
167 | CallCredentials,
|
168 | Deadline,
|
169 | Serialize as serialize,
|
170 | Deserialize as deserialize,
|
171 | ClientUnaryCall,
|
172 | ClientReadableStream,
|
173 | ClientWritableStream,
|
174 | ClientDuplexStream,
|
175 | CallOptions,
|
176 | MethodDefinition,
|
177 | StatusObject,
|
178 | ServiceError,
|
179 | ServerUnaryCall,
|
180 | ServerReadableStream,
|
181 | ServerWritableStream,
|
182 | ServerDuplexStream,
|
183 | ServerErrorResponse,
|
184 | ServiceDefinition,
|
185 | UntypedHandleCall,
|
186 | UntypedServiceImplementation,
|
187 | };
|
188 |
|
189 |
|
190 |
|
191 | export {
|
192 | handleBidiStreamingCall,
|
193 | handleServerStreamingCall,
|
194 | handleUnaryCall,
|
195 | handleClientStreamingCall,
|
196 | };
|
197 |
|
198 |
|
199 | export type Call =
|
200 | | ClientUnaryCall
|
201 | | ClientReadableStream<any>
|
202 | | ClientWritableStream<any>
|
203 | | ClientDuplexStream<any, any>;
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | export const loadObject = (value: any, options: any): never => {
|
211 | throw new Error(
|
212 | 'Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead'
|
213 | );
|
214 | };
|
215 |
|
216 | export const load = (filename: any, format: any, options: any): never => {
|
217 | throw new Error(
|
218 | 'Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead'
|
219 | );
|
220 | };
|
221 |
|
222 | export const setLogger = (logger: Partial<Console>): void => {
|
223 | logging.setLogger(logger);
|
224 | };
|
225 |
|
226 | export const setLogVerbosity = (verbosity: LogVerbosity): void => {
|
227 | logging.setLoggerVerbosity(verbosity);
|
228 | };
|
229 |
|
230 | export { Server };
|
231 | export { ServerCredentials };
|
232 | export { KeyCertPair };
|
233 |
|
234 | export const getClientChannel = (client: Client) => {
|
235 | return Client.prototype.getChannel.call(client);
|
236 | };
|
237 |
|
238 | export { StatusBuilder };
|
239 |
|
240 | export { Listener } from './call-stream';
|
241 |
|
242 | export {
|
243 | Requester,
|
244 | ListenerBuilder,
|
245 | RequesterBuilder,
|
246 | Interceptor,
|
247 | InterceptorOptions,
|
248 | InterceptorProvider,
|
249 | InterceptingCall,
|
250 | InterceptorConfigurationError,
|
251 | } from './client-interceptors';
|
252 |
|
253 | export {
|
254 | GrpcObject,
|
255 | ServiceClientConstructor,
|
256 | ProtobufTypeDefinition
|
257 | } from './make-client';
|
258 |
|
259 | export { ChannelOptions } from './channel-options';
|
260 |
|
261 | export {
|
262 | getChannelzServiceDefinition,
|
263 | getChannelzHandlers
|
264 | } from './channelz';
|
265 |
|
266 | export { addAdminServicesToServer } from './admin';
|
267 |
|
268 | import * as experimental from './experimental';
|
269 | export { experimental };
|
270 |
|
271 | import * as resolver_dns from './resolver-dns';
|
272 | import * as resolver_uds from './resolver-uds';
|
273 | import * as resolver_ip from './resolver-ip';
|
274 | import * as load_balancer_pick_first from './load-balancer-pick-first';
|
275 | import * as load_balancer_round_robin from './load-balancer-round-robin';
|
276 | import * as load_balancer_outlier_detection from './load-balancer-outlier-detection';
|
277 | import * as channelz from './channelz';
|
278 |
|
279 | const clientVersion = require('../../package.json').version;
|
280 |
|
281 | (() => {
|
282 | logging.trace(LogVerbosity.DEBUG, 'index', 'Loading @grpc/grpc-js version ' + clientVersion);
|
283 | resolver_dns.setup();
|
284 | resolver_uds.setup();
|
285 | resolver_ip.setup();
|
286 | load_balancer_pick_first.setup();
|
287 | load_balancer_round_robin.setup();
|
288 | load_balancer_outlier_detection.setup();
|
289 | channelz.setup();
|
290 | })();
|