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:
Ryan O'Hara-Reid
2021-09-11 13:52:07 +10:00
committed by GitHub
parent 72516f7268
commit d636049fb2
168 changed files with 8085 additions and 6996 deletions

View File

@@ -4,6 +4,7 @@
package slack
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -151,7 +152,17 @@ func (s *Slack) GetUsersInGroup(group string) []string {
// token and a channel
func (s *Slack) NewConnection() error {
if !s.Connected {
err := common.SendHTTPGetRequest(s.BuildURL(s.VerificationToken), true, s.Verbose, &s.Details)
contents, err := common.SendHTTPRequest(context.TODO(),
http.MethodGet,
s.BuildURL(s.VerificationToken),
nil,
nil,
s.Verbose)
if err != nil {
return err
}
err = json.Unmarshal(contents, &s.Details)
if err != nil {
return err
}

View File

@@ -2,6 +2,7 @@
package smsglobal
import (
"context"
"errors"
"flag"
"net/http"
@@ -179,15 +180,17 @@ func (s *SMSGlobal) SendMessage(to, message string) error {
headers := make(map[string]string)
headers["Content-Type"] = "application/x-www-form-urlencoded"
resp, err := common.SendHTTPRequest(http.MethodPost,
resp, err := common.SendHTTPRequest(context.TODO(),
http.MethodPost,
smsGlobalAPIURL,
headers,
strings.NewReader(values.Encode()))
strings.NewReader(values.Encode()),
s.Verbose)
if err != nil {
return err
}
if !strings.Contains(resp, "OK: 0; Sent queued message") {
if !strings.Contains(string(resp), "OK: 0; Sent queued message") {
return errSMSNotSent
}
return nil

View File

@@ -5,6 +5,7 @@ package telegram
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
@@ -245,13 +246,15 @@ func (t *Telegram) SendHTTPRequest(path string, data []byte, result interface{})
headers := make(map[string]string)
headers["content-type"] = "application/json"
resp, err := common.SendHTTPRequest(http.MethodPost,
resp, err := common.SendHTTPRequest(context.TODO(),
http.MethodPost,
path,
headers,
bytes.NewBuffer(data))
bytes.NewBuffer(data),
t.Verbose)
if err != nil {
return err
}
return json.Unmarshal([]byte(resp), result)
return json.Unmarshal(resp, result)
}