1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports["default"] = void 0;
|
9 |
|
10 | var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
11 |
|
12 | var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
13 |
|
14 | var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
15 |
|
16 | var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
17 |
|
18 | var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
19 |
|
20 | var _driver = require("./driver");
|
21 |
|
22 | var _error = require("./error");
|
23 |
|
24 | var _connectionProviderRouting = _interopRequireDefault(require("./internal/connection-provider-routing"));
|
25 |
|
26 | var _leastConnectedLoadBalancingStrategy = _interopRequireDefault(require("./internal/least-connected-load-balancing-strategy"));
|
27 |
|
28 | var _connectionErrorHandler = _interopRequireDefault(require("./internal/connection-error-handler"));
|
29 |
|
30 | var _configuredCustomResolver = _interopRequireDefault(require("./internal/resolver/configured-custom-resolver"));
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | var RoutingDriver =
|
56 |
|
57 | function (_Driver) {
|
58 | (0, _inherits2["default"])(RoutingDriver, _Driver);
|
59 |
|
60 | function RoutingDriver(address, routingContext, userAgent) {
|
61 | var _this;
|
62 |
|
63 | var token = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
64 | var config = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
65 | (0, _classCallCheck2["default"])(this, RoutingDriver);
|
66 | _this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(RoutingDriver).call(this, address, userAgent, token, validateConfig(config)));
|
67 | _this._routingContext = routingContext;
|
68 | return _this;
|
69 | }
|
70 |
|
71 | (0, _createClass2["default"])(RoutingDriver, [{
|
72 | key: "_afterConstruction",
|
73 | value: function _afterConstruction() {
|
74 | this._log.info("Routing driver ".concat(this._id, " created for server address ").concat(this._address));
|
75 | }
|
76 | }, {
|
77 | key: "_createConnectionProvider",
|
78 | value: function _createConnectionProvider(address, userAgent, authToken) {
|
79 | return new _connectionProviderRouting["default"]({
|
80 | id: this._id,
|
81 | address: address,
|
82 | routingContext: this._routingContext,
|
83 | hostNameResolver: createHostNameResolver(this._config),
|
84 | config: this._config,
|
85 | log: this._log,
|
86 | userAgent: userAgent,
|
87 | authToken: authToken
|
88 | });
|
89 | }
|
90 | }]);
|
91 | return RoutingDriver;
|
92 | }(_driver.Driver);
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | function createHostNameResolver(config) {
|
101 | return new _configuredCustomResolver["default"](config.resolver);
|
102 | }
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | function validateConfig(config) {
|
110 | var resolver = config.resolver;
|
111 |
|
112 | if (resolver && typeof resolver !== 'function') {
|
113 | throw new TypeError("Configured resolver should be a function. Got: ".concat(resolver));
|
114 | }
|
115 |
|
116 | return config;
|
117 | }
|
118 |
|
119 | var _default = RoutingDriver;
|
120 | exports["default"] = _default; |
\ | No newline at end of file |