mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 23:16:53 +00:00
exchanges: Initial context propagation (#744)
* gct: phase one context awareness pass * exchanges: context propagation pass * common/requester: force context requirement * gctcli/exchanges: linter fix * rpcserver: fix test using dummy rpc server * backtester: fix comments * grpc: add correct cancel and timeout for commands * rpcserver_test: add comment on dummy server * common: deprecated SendHTTPGetRequest * linter: fix * linter: turn on no context check * apichecker: fix context linter issue * binance: use param context * common: remove checks as this gets executed before main * common: change mutex to RW as clients can be used by multiple go routines. * common: remove init and JIT default client. Unexport global variables and add protection. * common: Add comments * bithumb: after dinner mints fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
@@ -43,7 +44,7 @@ func (w Wrapper) IsEnabled(exch string) (v bool) {
|
||||
}
|
||||
|
||||
// Orderbook validator for test execution/scripts
|
||||
func (w Wrapper) Orderbook(exch string, pair currency.Pair, item asset.Item) (*orderbook.Base, error) {
|
||||
func (w Wrapper) Orderbook(ctx context.Context, exch string, pair currency.Pair, item asset.Item) (*orderbook.Base, error) {
|
||||
if exch == exchError.String() {
|
||||
return nil, errTestFailed
|
||||
}
|
||||
@@ -68,7 +69,7 @@ func (w Wrapper) Orderbook(exch string, pair currency.Pair, item asset.Item) (*o
|
||||
}
|
||||
|
||||
// Ticker validator for test execution/scripts
|
||||
func (w Wrapper) Ticker(exch string, pair currency.Pair, item asset.Item) (*ticker.Price, error) {
|
||||
func (w Wrapper) Ticker(ctx context.Context, exch string, pair currency.Pair, item asset.Item) (*ticker.Price, error) {
|
||||
if exch == exchError.String() {
|
||||
return nil, errTestFailed
|
||||
}
|
||||
@@ -106,7 +107,7 @@ func (w Wrapper) Pairs(exch string, _ bool, _ asset.Item) (*currency.Pairs, erro
|
||||
}
|
||||
|
||||
// QueryOrder validator for test execution/scripts
|
||||
func (w Wrapper) QueryOrder(exch, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error) {
|
||||
func (w Wrapper) QueryOrder(ctx context.Context, exch, _ string, _ currency.Pair, _ asset.Item) (*order.Detail, error) {
|
||||
if exch == exchError.String() {
|
||||
return nil, errTestFailed
|
||||
}
|
||||
@@ -146,7 +147,7 @@ func (w Wrapper) QueryOrder(exch, _ string, _ currency.Pair, _ asset.Item) (*ord
|
||||
}
|
||||
|
||||
// SubmitOrder validator for test execution/scripts
|
||||
func (w Wrapper) SubmitOrder(o *order.Submit) (*order.SubmitResponse, error) {
|
||||
func (w Wrapper) SubmitOrder(ctx context.Context, o *order.Submit) (*order.SubmitResponse, error) {
|
||||
if o == nil {
|
||||
return nil, errTestFailed
|
||||
}
|
||||
@@ -167,7 +168,7 @@ func (w Wrapper) SubmitOrder(o *order.Submit) (*order.SubmitResponse, error) {
|
||||
}
|
||||
|
||||
// CancelOrder validator for test execution/scripts
|
||||
func (w Wrapper) CancelOrder(exch, orderid string, cp currency.Pair, a asset.Item) (bool, error) {
|
||||
func (w Wrapper) CancelOrder(ctx context.Context, exch, orderid string, cp currency.Pair, a asset.Item) (bool, error) {
|
||||
if exch == exchError.String() {
|
||||
return false, errTestFailed
|
||||
}
|
||||
@@ -184,7 +185,7 @@ func (w Wrapper) CancelOrder(exch, orderid string, cp currency.Pair, a asset.Ite
|
||||
}
|
||||
|
||||
// AccountInformation validator for test execution/scripts
|
||||
func (w Wrapper) AccountInformation(exch string, assetType asset.Item) (account.Holdings, error) {
|
||||
func (w Wrapper) AccountInformation(ctx context.Context, exch string, assetType asset.Item) (account.Holdings, error) {
|
||||
if exch == exchError.String() {
|
||||
return account.Holdings{}, errTestFailed
|
||||
}
|
||||
@@ -224,7 +225,7 @@ func (w Wrapper) DepositAddress(exch string, _ currency.Code) (string, error) {
|
||||
}
|
||||
|
||||
// WithdrawalCryptoFunds validator for test execution/scripts
|
||||
func (w Wrapper) WithdrawalCryptoFunds(r *withdraw.Request) (out string, err error) {
|
||||
func (w Wrapper) WithdrawalCryptoFunds(ctx context.Context, r *withdraw.Request) (out string, err error) {
|
||||
if r.Exchange == exchError.String() {
|
||||
return r.Exchange, errTestFailed
|
||||
}
|
||||
@@ -233,7 +234,7 @@ func (w Wrapper) WithdrawalCryptoFunds(r *withdraw.Request) (out string, err err
|
||||
}
|
||||
|
||||
// WithdrawalFiatFunds validator for test execution/scripts
|
||||
func (w Wrapper) WithdrawalFiatFunds(_ string, r *withdraw.Request) (out string, err error) {
|
||||
func (w Wrapper) WithdrawalFiatFunds(ctx context.Context, _ string, r *withdraw.Request) (out string, err error) {
|
||||
if r.Exchange == exchError.String() {
|
||||
return r.Exchange, errTestFailed
|
||||
}
|
||||
@@ -242,7 +243,7 @@ func (w Wrapper) WithdrawalFiatFunds(_ string, r *withdraw.Request) (out string,
|
||||
}
|
||||
|
||||
// OHLCV returns open high low close volume candles for requested exchange/pair/asset/start & end time
|
||||
func (w Wrapper) OHLCV(exch string, p currency.Pair, a asset.Item, start, end time.Time, i kline.Interval) (kline.Item, error) {
|
||||
func (w Wrapper) OHLCV(ctx context.Context, exch string, p currency.Pair, a asset.Item, start, end time.Time, i kline.Interval) (kline.Item, error) {
|
||||
if exch == exchError.String() {
|
||||
return kline.Item{}, errTestFailed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user