package org.nlab.smtp.pool;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import java.util.concurrent.TimeUnit;

/**
 * Created by nlabrot on 12/06/17.
 */
public class PoolConfigs {

  /**
   * Default {@link GenericObjectPoolConfig} config
   * @return
   */
  public static GenericObjectPoolConfig defaultConfig() {
    return new GenericObjectPoolConfig();
  }

  /**
   * Default {@link GenericObjectPoolConfig} config
   *  {@link GenericObjectPoolConfig#getTestOnBorrow} : true
   *  minIdle: 0
   *  maxIdle: 8
   *  maxTotal: 8
   *  maxWaitMillis: 10000
   *  minEvictableIdleTimeMillis: 5 minutes
   *  timeBetweenEvictionRunsMillis: 10 seconds
   *
   * @return
   */
  public static GenericObjectPoolConfig standardConfig() {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setTestOnBorrow(true);
    config.setMinIdle(0);
    config.setMaxIdle(8);
    config.setMaxTotal(8);

    config.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(5));
    config.setTimeBetweenEvictionRunsMillis(10000);


    config.setMaxWaitMillis(10000);
    return config;
  }


  /**
   *
   * @param minIdle
   * @param maxIdle
   * @param maxTotal
   * @param maxWaitMillis
   * @param minEvictableIdleTimeMillis
   * @param timeBetweenEvictionRunsMillis
   * @return
   */
  public static GenericObjectPoolConfig standardConfig(int minIdle, int maxIdle, int maxTotal, int maxWaitMillis, int minEvictableIdleTimeMillis, int timeBetweenEvictionRunsMillis) {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setTestOnBorrow(true);
    config.setMinIdle(minIdle);
    config.setMaxIdle(maxIdle);
    config.setMaxTotal(maxTotal);

    config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    config.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);


    config.setMaxWaitMillis(maxWaitMillis);
    return config;
  }
}

@@ -128,16 +128,78 @@
 t;%0A%0A/**%0A
+ * Ease pool configuration with default pool configuration%0A *%0A
  * Creat
@@ -311,24 +311,84 @@
 fig%7D config%0A
+   * See default parameters %7B@link GenericObjectPoolConfig%7D%0A
    * @return

Add toString to ConnectionStrategyFactory Remove redundant isConnected Add GenericPoolConfig configs