All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sxtanna.db.config.KueryConfig.kt Maven / Gradle / Ivy

There is a newer version: 1.6
Show newest version
package com.sxtanna.db.config

/**
 * Contains the various configuration options available
 */
data class KueryConfig(val data : OptionsData, val pool : OptionsPool, val user : OptionsUser) {
    internal constructor() : this(OptionsData(), OptionsPool(), OptionsUser())


    /**
     * Holds the data used to connect to the database
     *  * IP Address
     *  * Port
     *  * Database name
     */
    data class OptionsData(val address : String, val port : Short, val database : String) {
        internal constructor() : this("", 3306, "")
    }

    /**
     * Holds the data used to configure the pool
     *  * Custom Pool name
     *  * Pooled connections size
     *  * Idle Connection timeout (milliseconds)
     *  * Connecting Connection timeout (milliseconds)
     */
    data class OptionsPool(val name : String, val size : Int, val connTimeout : Long, val idleTimeout : Long) {
        internal constructor() : this("KueryPool", 10, 1_000L, 10_000L)

        init {
            require(connTimeout >= 250) { "Minimum connection timeout is 250 milliseconds" }
            require(idleTimeout >= 10_000L) { "Minimum idle timeout is 10,000 milliseconds (10 seconds)" }
        }

    }

    /**
     * Holds the data used to authenticate on the server
     *  * Username
     *  * Password
     */
    data class OptionsUser(val name : String, val auth : String) {
        internal constructor() : this("", "")
    }


    companion object {

        val DEFAULT = KueryConfig()

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy