mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +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 engine
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -210,10 +211,22 @@ func validateSettings(b *Engine, s *Settings, flagSet map[string]bool) {
|
||||
if b.Settings.GlobalHTTPTimeout <= 0 {
|
||||
b.Settings.GlobalHTTPTimeout = b.Config.GlobalHTTPTimeout
|
||||
}
|
||||
common.SetHTTPClientWithTimeout(b.Settings.GlobalHTTPTimeout)
|
||||
|
||||
err := common.SetHTTPClientWithTimeout(b.Settings.GlobalHTTPTimeout)
|
||||
if err != nil {
|
||||
gctlog.Errorf(gctlog.Global,
|
||||
"Could not set new HTTP Client with timeout %s error: %v",
|
||||
b.Settings.GlobalHTTPTimeout,
|
||||
err)
|
||||
}
|
||||
|
||||
if b.Settings.GlobalHTTPUserAgent != "" {
|
||||
common.HTTPUserAgent = b.Settings.GlobalHTTPUserAgent
|
||||
err = common.SetHTTPUserAgent(b.Settings.GlobalHTTPUserAgent)
|
||||
if err != nil {
|
||||
gctlog.Errorf(gctlog.Global, "Could not set HTTP User Agent for %s error: %v",
|
||||
b.Settings.GlobalHTTPUserAgent,
|
||||
err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +822,7 @@ func (bot *Engine) LoadExchange(name string, wg *sync.WaitGroup) error {
|
||||
useAsset = assetTypes[a]
|
||||
break
|
||||
}
|
||||
err = exch.ValidateCredentials(useAsset)
|
||||
err = exch.ValidateCredentials(context.TODO(), useAsset)
|
||||
if err != nil {
|
||||
gctlog.Warnf(gctlog.ExchangeSys,
|
||||
"%s: Cannot validate credentials, authenticated support has been disabled, Error: %s\n",
|
||||
|
||||
Reference in New Issue
Block a user