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