package com.steerinfo.meterwork.rtdb;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(RtdbPoolProperties.class)
public class RtdbClientConfiguration {

    @Bean(destroyMethod = "close")
    @ConditionalOnProperty(name = "rtdb.monitor.enabled", havingValue = "true", matchIfMissing = true)
    public RtdbClientPool rtdbClientPool(RtdbPoolProperties properties) {
        return new RtdbClientPool(properties);
    }
}
