diffusion
Version:
Diffusion JavaScript client
72 lines (71 loc) • 3.35 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrimaryInitiatorBuilderImpl = void 0;
var errors_1 = require("./../../../errors/errors");
var remote_servers_1 = require("./../../../features/remote-servers");
var remote_server_definition_1 = require("./../../services/remote-servers/remote-server-definition");
var require_non_null_1 = require("./../../util/require-non-null");
var remote_server_builder_base_1 = require("./remote-server-builder-base");
/**
* Implementation of {@link PrimaryInitiatorBuilder}.
*
* @since 6.9
*/
var PrimaryInitiatorBuilderImpl = /** @class */ (function (_super) {
__extends(PrimaryInitiatorBuilderImpl, _super);
/**
* Constructor.
*/
function PrimaryInitiatorBuilderImpl() {
var _this = _super.call(this, remote_servers_1.RemoteServerType.PRIMARY_INITIATOR) || this;
_this.theRetryDelay = 1000;
return _this;
}
PrimaryInitiatorBuilderImpl.validateConnector = function (connector) {
require_non_null_1.requireNonNull(connector, 'connector');
var trimmedName = connector.trim();
if (trimmedName.length === 0) {
throw new errors_1.IllegalArgumentError('Non whitespace connector must be supplied');
}
return trimmedName;
};
PrimaryInitiatorBuilderImpl.prototype.validateUrls = function (urls) {
var _this = this;
if (urls.length === 0) {
throw new errors_1.IllegalArgumentError('urls is empty');
}
return urls.map(function (url) { return _this.validateUrl(url); });
};
PrimaryInitiatorBuilderImpl.prototype.retryDelay = function (delay) {
require_non_null_1.requireNonNull(delay, 'delay');
if (delay < 0) {
throw new errors_1.IllegalArgumentError('delay is invalid');
}
this.theRetryDelay = delay;
return this;
};
PrimaryInitiatorBuilderImpl.prototype.reset = function () {
this.theRetryDelay = 1000;
return this;
};
PrimaryInitiatorBuilderImpl.prototype.build = function (name, urls, connector) {
return remote_server_definition_1.RemoteServerDefinitionImpl.createPrimaryDefinition(PrimaryInitiatorBuilderImpl.validateName(name), this.validateUrls(require_non_null_1.requireNonNull(urls, 'urls')), this.theRetryDelay, PrimaryInitiatorBuilderImpl.validateConnector(connector));
};
return PrimaryInitiatorBuilderImpl;
}(remote_server_builder_base_1.RemoteServerBuilderBaseImpl));
exports.PrimaryInitiatorBuilderImpl = PrimaryInitiatorBuilderImpl;