"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cassandra = require("cassandra-driver");
class CustomCassandraConnectionPool {
    constructor(options, errorCallback, successCallback, callbackStatus) {
        this.client = null;
        this.options = options;
        if (this.options.user == undefined || this.options.password == undefined) {
            errorCallback("User and password are required");
            return;
        }
        let authProvider = new cassandra.auth.PlainTextAuthProvider(this.options.user, this.options.password);
        if (this.options.hosts == undefined || this.options.port == undefined) {
            errorCallback("Host and port are required");
            return;
        }
        let clientOptions = {
            contactPoints: this.options.hosts,
            keyspace: this.options.keyspace,
            authProvider: authProvider,
            protocolOptions: {
                port: this.options.port,
                maxSchemaAgreementWaitSeconds: 10,
                maxVersion: 0 //Default values can be find in "cassandra-driver/lib/client-options.js:52"
            }
        };
        this.client = new cassandra.Client(clientOptions);
        this.client.controlConnection.on('newConnection', function (err, connection, host) {
            callbackStatus(err);
        });
        this.client.connect(function (err) {
            if (err)
                errorCallback(err);
            else
                successCallback();
        });
    }
}
exports.default = CustomCassandraConnectionPool;
//# sourceMappingURL=customCassandraPool.js.map