refactor exchange rates data backend, supports multi data source, supports timeout

This commit is contained in:
MaysWind
2021-01-10 01:07:37 +08:00
parent 170780a631
commit dff54fd174
9 changed files with 211 additions and 85 deletions
@@ -0,0 +1,15 @@
package exchangerates
import (
"github.com/mayswind/lab/pkg/core"
"github.com/mayswind/lab/pkg/models"
)
// ExchangeRatesDataSource defines the structure of exchange rates data source
type ExchangeRatesDataSource interface {
// GetRequestUrl returns the data source url
GetRequestUrl() string
// Parse returns the common response entity according to the data source raw response
Parse(c *core.Context, content []byte) (*models.LatestExchangeRateResponse, error)
}