all: rename types.MarginHistory to types.MarginHistoryService

This commit is contained in:
c9s 2023-03-26 00:53:43 +08:00
parent 265b69a0ee
commit 6ea399dc8e
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
8 changed files with 19 additions and 19 deletions

View File

@ -88,9 +88,9 @@ var marginLoansCmd = &cobra.Command{
return errors.New("session is not set") return errors.New("session is not set")
} }
marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistory) marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistoryService)
if !ok { if !ok {
return fmt.Errorf("exchange %s does not support MarginHistory service", selectedSession.ExchangeName) return fmt.Errorf("exchange %s does not support MarginHistoryService service", selectedSession.ExchangeName)
} }
now := time.Now() now := time.Now()
@ -127,9 +127,9 @@ var marginRepaysCmd = &cobra.Command{
return errors.New("session is not set") return errors.New("session is not set")
} }
marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistory) marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistoryService)
if !ok { if !ok {
return fmt.Errorf("exchange %s does not support MarginHistory service", selectedSession.ExchangeName) return fmt.Errorf("exchange %s does not support MarginHistoryService service", selectedSession.ExchangeName)
} }
now := time.Now() now := time.Now()
@ -166,9 +166,9 @@ var marginInterestsCmd = &cobra.Command{
return errors.New("session is not set") return errors.New("session is not set")
} }
marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistory) marginHistoryService, ok := selectedSession.Exchange.(types.MarginHistoryService)
if !ok { if !ok {
return fmt.Errorf("exchange %s does not support MarginHistory service", selectedSession.ExchangeName) return fmt.Errorf("exchange %s does not support MarginHistoryService service", selectedSession.ExchangeName)
} }
now := time.Now() now := time.Now()

View File

@ -10,7 +10,7 @@ import (
) )
type MarginInterestBatchQuery struct { type MarginInterestBatchQuery struct {
types.MarginHistory types.MarginHistoryService
} }
func (e *MarginInterestBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginInterest, errC chan error) { func (e *MarginInterestBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginInterest, errC chan error) {

View File

@ -11,7 +11,7 @@ import (
) )
type MarginLiquidationBatchQuery struct { type MarginLiquidationBatchQuery struct {
types.MarginHistory types.MarginHistoryService
} }
func (e *MarginLiquidationBatchQuery) Query(ctx context.Context, startTime, endTime time.Time) (c chan types.MarginLiquidation, errC chan error) { func (e *MarginLiquidationBatchQuery) Query(ctx context.Context, startTime, endTime time.Time) (c chan types.MarginLiquidation, errC chan error) {

View File

@ -11,7 +11,7 @@ import (
) )
type MarginLoanBatchQuery struct { type MarginLoanBatchQuery struct {
types.MarginHistory types.MarginHistoryService
} }
func (e *MarginLoanBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginLoan, errC chan error) { func (e *MarginLoanBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginLoan, errC chan error) {

View File

@ -11,7 +11,7 @@ import (
) )
type MarginRepayBatchQuery struct { type MarginRepayBatchQuery struct {
types.MarginHistory types.MarginHistoryService
} }
func (e *MarginRepayBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginRepay, errC chan error) { func (e *MarginRepayBatchQuery) Query(ctx context.Context, asset string, startTime, endTime time.Time) (c chan types.MarginRepay, errC chan error) {

View File

@ -17,7 +17,7 @@ type MarginService struct {
} }
func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset string, startTime time.Time) error { func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset string, startTime time.Time) error {
api, ok := ex.(types.MarginHistory) api, ok := ex.(types.MarginHistoryService)
if !ok { if !ok {
return nil return nil
} }
@ -38,7 +38,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
Type: types.MarginLoan{}, Type: types.MarginLoan{},
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) { BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
query := &batch.MarginLoanBatchQuery{ query := &batch.MarginLoanBatchQuery{
MarginHistory: api, MarginHistoryService: api,
} }
return query.Query(ctx, asset, startTime, endTime) return query.Query(ctx, asset, startTime, endTime)
}, },
@ -55,7 +55,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
Type: types.MarginRepay{}, Type: types.MarginRepay{},
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) { BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
query := &batch.MarginRepayBatchQuery{ query := &batch.MarginRepayBatchQuery{
MarginHistory: api, MarginHistoryService: api,
} }
return query.Query(ctx, asset, startTime, endTime) return query.Query(ctx, asset, startTime, endTime)
}, },
@ -72,7 +72,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
Type: types.MarginInterest{}, Type: types.MarginInterest{},
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) { BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
query := &batch.MarginInterestBatchQuery{ query := &batch.MarginInterestBatchQuery{
MarginHistory: api, MarginHistoryService: api,
} }
return query.Query(ctx, asset, startTime, endTime) return query.Query(ctx, asset, startTime, endTime)
}, },
@ -90,7 +90,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
Type: types.MarginLiquidation{}, Type: types.MarginLiquidation{},
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) { BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
query := &batch.MarginLiquidationBatchQuery{ query := &batch.MarginLiquidationBatchQuery{
MarginHistory: api, MarginHistoryService: api,
} }
return query.Query(ctx, startTime, endTime) return query.Query(ctx, startTime, endTime)
}, },

View File

@ -49,8 +49,8 @@ func (s *SyncService) SyncSessionSymbols(ctx context.Context, exchange types.Exc
} }
func (s *SyncService) SyncMarginHistory(ctx context.Context, exchange types.Exchange, startTime time.Time, assets ...string) error { func (s *SyncService) SyncMarginHistory(ctx context.Context, exchange types.Exchange, startTime time.Time, assets ...string) error {
if _, implemented := exchange.(types.MarginHistory); !implemented { if _, implemented := exchange.(types.MarginHistoryService); !implemented {
log.Debugf("exchange %T does not support types.MarginHistory", exchange) log.Debugf("exchange %T does not support types.MarginHistoryService", exchange)
return nil return nil
} }

View File

@ -105,8 +105,8 @@ type MarginLiquidation struct {
UpdatedTime Time `json:"updatedTime" db:"time"` UpdatedTime Time `json:"updatedTime" db:"time"`
} }
// MarginHistory provides the service of querying loan history and repay history // MarginHistoryService provides the service of querying loan history and repay history
type MarginHistory interface { type MarginHistoryService interface {
QueryLoanHistory(ctx context.Context, asset string, startTime, endTime *time.Time) ([]MarginLoan, error) QueryLoanHistory(ctx context.Context, asset string, startTime, endTime *time.Time) ([]MarginLoan, error)
QueryRepayHistory(ctx context.Context, asset string, startTime, endTime *time.Time) ([]MarginRepay, error) QueryRepayHistory(ctx context.Context, asset string, startTime, endTime *time.Time) ([]MarginRepay, error)
QueryLiquidationHistory(ctx context.Context, startTime, endTime *time.Time) ([]MarginLiquidation, error) QueryLiquidationHistory(ctx context.Context, startTime, endTime *time.Time) ([]MarginLiquidation, error)