diffusion
Version:
Diffusion JavaScript client
60 lines (59 loc) • 3.1 kB
JavaScript
;
/**
* @module Services.RemoteServers
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoteServerDefinitionImpl = void 0;
var remote_servers_1 = require("../../../features/remote-servers");
/**
* The request of RemoteServers CREATE_REMOTE_SERVER service
*/
var RemoteServerDefinitionImpl = /** @class */ (function () {
/**
* Create a new NamedRemoteServerSpecification instance
*
* @param name the remote server name
* @param url the remote server url
* @param principal the principal used for connection to the remote server
* @param credentials the credentials used for connection to the remote server
* @param connectionOptions the options used for connection to the remote server
*/
function RemoteServerDefinitionImpl(type, name, urls, principal, connectionOptions, credentials, connector, missingTopicNotificationFilter) {
var _a;
this.type = type;
this.name = name;
this.url = urls[0];
this.urls = urls;
this.principal = principal;
this.credentials = credentials;
this.connectionOptions = connectionOptions;
this.connector = connector;
this.missingTopicNotificationFilter = missingTopicNotificationFilter;
this.primaryHostName = urls[0];
this.retryDelay = parseInt((_a = connectionOptions[remote_servers_1.ConnectionOption.RETRY_DELAY]) !== null && _a !== void 0 ? _a : '1000', 10);
}
/**
* Create a primary initiator definition.
*/
RemoteServerDefinitionImpl.createPrimaryDefinition = function (name, urls, retryDelay, connector) {
var _a;
return new RemoteServerDefinitionImpl(remote_servers_1.RemoteServerType.PRIMARY_INITIATOR, name, urls, '', (_a = {}, _a[remote_servers_1.ConnectionOption.RETRY_DELAY] = "" + retryDelay, _a), null, connector);
};
/**
* Generate a secondary initiator definition.
*/
RemoteServerDefinitionImpl.createSecondaryDefinition = function (type, name, url, principal, connectionOptions, missingTopicNotificationFilter, credentials) {
return new RemoteServerDefinitionImpl(type, name, [url], principal, connectionOptions, credentials, undefined, missingTopicNotificationFilter);
};
/**
* Construct from a remote server and some credentials.
*/
RemoteServerDefinitionImpl.createDefinition = function (remoteServer, credentials) {
return new RemoteServerDefinitionImpl(remoteServer.type, remoteServer.name, remoteServer.urls, remoteServer.principal, remoteServer.connectionOptions, credentials, remoteServer.connector, remoteServer.missingTopicNotificationFilter);
};
RemoteServerDefinitionImpl.prototype.withOptions = function (options) {
return new RemoteServerDefinitionImpl(this.type, this.name, this.urls, this.principal, options, this.credentials, this.connector, this.missingTopicNotificationFilter);
};
return RemoteServerDefinitionImpl;
}());
exports.RemoteServerDefinitionImpl = RemoteServerDefinitionImpl;