mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 08:14:25 +08:00
refactor exchange rates data backend, supports multi data source, supports timeout
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package exchangerates
|
||||
|
||||
import (
|
||||
"github.com/mayswind/lab/pkg/errs"
|
||||
"github.com/mayswind/lab/pkg/settings"
|
||||
)
|
||||
|
||||
// ExchangeRatesDataSourceContainer contains the current exchange rates data source
|
||||
type ExchangeRatesDataSourceContainer struct {
|
||||
Current ExchangeRatesDataSource
|
||||
}
|
||||
|
||||
// Initialize a exchange rates data source container singleton instance
|
||||
var (
|
||||
Container = &ExchangeRatesDataSourceContainer{}
|
||||
)
|
||||
|
||||
// InitializeExchangeRatesDataSource initializes the current exchange rates data source according to the config
|
||||
func InitializeExchangeRatesDataSource(config *settings.Config) error {
|
||||
if config.ExchangeRatesDataSource == settings.EuroCentralBankDataSource {
|
||||
Container.Current = &EuroCentralBankDataSource{}
|
||||
return nil
|
||||
}
|
||||
|
||||
return errs.ErrInvalidExchangeRatesDataSource
|
||||
}
|
||||
Reference in New Issue
Block a user