package com.nisemoe.nise.config

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.jdbc.DataSourceBuilder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.transaction.annotation.EnableTransactionManagement
import javax.sql.DataSource

@Configuration
@EnableTransactionManagement
class DataSourceConfig {
    @Primary
    @Bean(name = ["niseDataSource"])
    @ConfigurationProperties(prefix = "spring.datasource.nise")
    fun niseDataSource(): DataSource = DataSourceBuilder.create().build()

    @Bean(name = ["replayCacheDataSource"])
    @ConfigurationProperties(prefix = "spring.datasource.replay-cache")
    fun replayCacheDataSource(): DataSource = DataSourceBuilder.create().build()
}
