import { Factory } from 'generic-pool';
import { DBTransaction } from './DBTransaction';
import { ConnectionPool, ConnectionConfig, PoolConfig } from './ConnectionPool';
/**
 * Configuration for a DBClient, this includes master and slave connection pool configurations.
 * Only the master pool config is necessary, if a slave pool is specified, any readonly transactions will use it. If not,
 * all transactions will use the master connection pool.
 */
export interface DBClientConfig<C extends ConnectionConfig> {
    name: string;
    master: PoolConfig<C>;
    slave?: PoolConfig<C>;
}
export declare abstract class DBClient<C, T extends DBTransaction<C>, CC extends ConnectionConfig, PC extends DBClientConfig<CC>> {
    static startMethod: string;
    static stopMethod: string;
    clientConfiguration: PC;
    name: string;
    masterPool: ConnectionPool<C>;
    slavePool: ConnectionPool<C>;
    constructor(clientConfiguration: PC);
    abstract getNewDBTransaction(readonly: boolean, connectionPool: ConnectionPool<C>): T;
    abstract getDefaultConnectionConfig(): CC;
    /**
     * Runs a function in a transaction. The function must receive one parameter that will be of class
     * {MysqlTransaction} and that you need to use to run all queries in this transaction
     *
     * @param {boolean} readonly Whether the transaction needs to be readonly or not
     * @param {Function} func A function that returns a promise that will execute all the queries wanted in this transaction
     * @returns {Promise} A promise that will execute the whole transaction
     */
    runInTransaction(readonly: boolean, func: (transaction: DBTransaction<C>) => Promise<any>): Promise<any>;
    getPoolForReadonly(readonly: boolean): ConnectionPool<C>;
    /**
     * Shorthand for a single readonly query
     * @param sql query to run
     * @param binds binds
     */
    read<P>(sql: string, ...binds: any[]): Promise<P[]>;
    /**
     * Shorthand to run a single sql.
     * Easy to mock
     * @param readonly
     * @param sql
     * @param binds
     */
    executeSql(readonly: boolean, sql: string, ...binds: any[]): Promise<any>;
    abstract getConnectionFactory(name: string, connectionConfig: CC): Factory<C>;
    initialise(): Promise<void>;
    stop(): Promise<void>;
    ping(readonly: boolean): Promise<void>;
    abstract getPingQuery(): string;
}
