UNPKG

9.23 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2019 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.experimental = exports.addAdminServicesToServer = exports.getChannelzHandlers = exports.getChannelzServiceDefinition = exports.InterceptorConfigurationError = exports.InterceptingCall = exports.RequesterBuilder = exports.ListenerBuilder = exports.StatusBuilder = exports.getClientChannel = exports.ServerCredentials = exports.Server = exports.setLogVerbosity = exports.setLogger = exports.load = exports.loadObject = exports.CallCredentials = exports.ChannelCredentials = exports.waitForClientReady = exports.closeClient = exports.Channel = exports.makeGenericClientConstructor = exports.makeClientConstructor = exports.loadPackageDefinition = exports.Client = exports.compressionAlgorithms = exports.propagate = exports.connectivityState = exports.status = exports.logVerbosity = exports.Metadata = exports.credentials = void 0;
20const call_credentials_1 = require("./call-credentials");
21Object.defineProperty(exports, "CallCredentials", { enumerable: true, get: function () { return call_credentials_1.CallCredentials; } });
22const channel_1 = require("./channel");
23Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return channel_1.ChannelImplementation; } });
24const compression_algorithms_1 = require("./compression-algorithms");
25Object.defineProperty(exports, "compressionAlgorithms", { enumerable: true, get: function () { return compression_algorithms_1.CompressionAlgorithms; } });
26const connectivity_state_1 = require("./connectivity-state");
27Object.defineProperty(exports, "connectivityState", { enumerable: true, get: function () { return connectivity_state_1.ConnectivityState; } });
28const channel_credentials_1 = require("./channel-credentials");
29Object.defineProperty(exports, "ChannelCredentials", { enumerable: true, get: function () { return channel_credentials_1.ChannelCredentials; } });
30const client_1 = require("./client");
31Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
32const constants_1 = require("./constants");
33Object.defineProperty(exports, "logVerbosity", { enumerable: true, get: function () { return constants_1.LogVerbosity; } });
34Object.defineProperty(exports, "status", { enumerable: true, get: function () { return constants_1.Status; } });
35Object.defineProperty(exports, "propagate", { enumerable: true, get: function () { return constants_1.Propagate; } });
36const logging = require("./logging");
37const make_client_1 = require("./make-client");
38Object.defineProperty(exports, "loadPackageDefinition", { enumerable: true, get: function () { return make_client_1.loadPackageDefinition; } });
39Object.defineProperty(exports, "makeClientConstructor", { enumerable: true, get: function () { return make_client_1.makeClientConstructor; } });
40Object.defineProperty(exports, "makeGenericClientConstructor", { enumerable: true, get: function () { return make_client_1.makeClientConstructor; } });
41const metadata_1 = require("./metadata");
42Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return metadata_1.Metadata; } });
43const server_1 = require("./server");
44Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
45const server_credentials_1 = require("./server-credentials");
46Object.defineProperty(exports, "ServerCredentials", { enumerable: true, get: function () { return server_credentials_1.ServerCredentials; } });
47const status_builder_1 = require("./status-builder");
48Object.defineProperty(exports, "StatusBuilder", { enumerable: true, get: function () { return status_builder_1.StatusBuilder; } });
49/**** Client Credentials ****/
50// Using assign only copies enumerable properties, which is what we want
51exports.credentials = {
52 /**
53 * Combine a ChannelCredentials with any number of CallCredentials into a
54 * single ChannelCredentials object.
55 * @param channelCredentials The ChannelCredentials object.
56 * @param callCredentials Any number of CallCredentials objects.
57 * @return The resulting ChannelCredentials object.
58 */
59 combineChannelCredentials: (channelCredentials, ...callCredentials) => {
60 return callCredentials.reduce((acc, other) => acc.compose(other), channelCredentials);
61 },
62 /**
63 * Combine any number of CallCredentials into a single CallCredentials
64 * object.
65 * @param first The first CallCredentials object.
66 * @param additional Any number of additional CallCredentials objects.
67 * @return The resulting CallCredentials object.
68 */
69 combineCallCredentials: (first, ...additional) => {
70 return additional.reduce((acc, other) => acc.compose(other), first);
71 },
72 // from channel-credentials.ts
73 createInsecure: channel_credentials_1.ChannelCredentials.createInsecure,
74 createSsl: channel_credentials_1.ChannelCredentials.createSsl,
75 createFromSecureContext: channel_credentials_1.ChannelCredentials.createFromSecureContext,
76 // from call-credentials.ts
77 createFromMetadataGenerator: call_credentials_1.CallCredentials.createFromMetadataGenerator,
78 createFromGoogleCredential: call_credentials_1.CallCredentials.createFromGoogleCredential,
79 createEmpty: call_credentials_1.CallCredentials.createEmpty,
80};
81/**
82 * Close a Client object.
83 * @param client The client to close.
84 */
85const closeClient = (client) => client.close();
86exports.closeClient = closeClient;
87const waitForClientReady = (client, deadline, callback) => client.waitForReady(deadline, callback);
88exports.waitForClientReady = waitForClientReady;
89/* eslint-enable @typescript-eslint/no-explicit-any */
90/**** Unimplemented function stubs ****/
91/* eslint-disable @typescript-eslint/no-explicit-any */
92const loadObject = (value, options) => {
93 throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
94};
95exports.loadObject = loadObject;
96const load = (filename, format, options) => {
97 throw new Error('Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead');
98};
99exports.load = load;
100const setLogger = (logger) => {
101 logging.setLogger(logger);
102};
103exports.setLogger = setLogger;
104const setLogVerbosity = (verbosity) => {
105 logging.setLoggerVerbosity(verbosity);
106};
107exports.setLogVerbosity = setLogVerbosity;
108const getClientChannel = (client) => {
109 return client_1.Client.prototype.getChannel.call(client);
110};
111exports.getClientChannel = getClientChannel;
112var client_interceptors_1 = require("./client-interceptors");
113Object.defineProperty(exports, "ListenerBuilder", { enumerable: true, get: function () { return client_interceptors_1.ListenerBuilder; } });
114Object.defineProperty(exports, "RequesterBuilder", { enumerable: true, get: function () { return client_interceptors_1.RequesterBuilder; } });
115Object.defineProperty(exports, "InterceptingCall", { enumerable: true, get: function () { return client_interceptors_1.InterceptingCall; } });
116Object.defineProperty(exports, "InterceptorConfigurationError", { enumerable: true, get: function () { return client_interceptors_1.InterceptorConfigurationError; } });
117var channelz_1 = require("./channelz");
118Object.defineProperty(exports, "getChannelzServiceDefinition", { enumerable: true, get: function () { return channelz_1.getChannelzServiceDefinition; } });
119Object.defineProperty(exports, "getChannelzHandlers", { enumerable: true, get: function () { return channelz_1.getChannelzHandlers; } });
120var admin_1 = require("./admin");
121Object.defineProperty(exports, "addAdminServicesToServer", { enumerable: true, get: function () { return admin_1.addAdminServicesToServer; } });
122const experimental = require("./experimental");
123exports.experimental = experimental;
124const resolver_dns = require("./resolver-dns");
125const resolver_uds = require("./resolver-uds");
126const resolver_ip = require("./resolver-ip");
127const load_balancer_pick_first = require("./load-balancer-pick-first");
128const load_balancer_round_robin = require("./load-balancer-round-robin");
129const load_balancer_outlier_detection = require("./load-balancer-outlier-detection");
130const channelz = require("./channelz");
131const clientVersion = require('../../package.json').version;
132(() => {
133 logging.trace(constants_1.LogVerbosity.DEBUG, 'index', 'Loading @grpc/grpc-js version ' + clientVersion);
134 resolver_dns.setup();
135 resolver_uds.setup();
136 resolver_ip.setup();
137 load_balancer_pick_first.setup();
138 load_balancer_round_robin.setup();
139 load_balancer_outlier_detection.setup();
140 channelz.setup();
141})();
142//# sourceMappingURL=index.js.map
\No newline at end of file