package com.atlassian.bitbucket.mesh;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DurationUnit;

import java.time.Duration;
import java.time.temporal.ChronoUnit;

@ConfigurationProperties("database.pool")
public class DatabasePoolProperties {

    @DurationUnit(ChronoUnit.SECONDS)
    private Duration connectTimeout;
    private int idleSize;
    @DurationUnit(ChronoUnit.MINUTES)
    private Duration idleTimeout;
    @DurationUnit(ChronoUnit.MINUTES)
    private Duration leakTimeout;
    @DurationUnit(ChronoUnit.MINUTES)
    private Duration lifetimeTimeout;
    private int maxSize;

    public DatabasePoolProperties() {
    }

    public Duration getConnectTimeout() {
        return connectTimeout;
    }

    public int getIdleSize() {
        return idleSize;
    }

    public Duration getIdleTimeout() {
        return idleTimeout;
    }

    public Duration getLeakTimeout() {
        return leakTimeout;
    }

    public Duration getLifetimeTimeout() {
        return lifetimeTimeout;
    }

    public int getMaxSize() {
        return maxSize;
    }

    public void setConnectTimeout(Duration connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    public void setIdleSize(int idleSize) {
        this.idleSize = idleSize;
    }

    public void setIdleTimeout(Duration idleTimeout) {
        this.idleTimeout = idleTimeout;
    }

    public void setLeakTimeout(Duration leakTimeout) {
        this.leakTimeout = leakTimeout;
    }

    public void setLifetimeTimeout(Duration lifetimeTimeout) {
        this.lifetimeTimeout = lifetimeTimeout;
    }

    public void setMaxSize(int maxSize) {
        this.maxSize = maxSize;
    }
}
