Skip to content

Commit

Permalink
Move timeout constant to rpcrouter package
Browse files Browse the repository at this point in the history
  • Loading branch information
anbsky committed Apr 23, 2020
1 parent 77ce145 commit 253e39b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var logger = monitor.NewModuleLogger("proxy")
const (
walletLoadRetries = 3
walletLoadRetryWait = 100 * time.Millisecond
rpcTimeout = 30 * time.Second
)

// Caller patches through JSON-RPC requests from clients, doing pre/post-processing,
Expand All @@ -53,7 +52,7 @@ type Caller struct {
func NewCaller(endpoint string, userID int) *Caller {
return &Caller{
client: jsonrpc.NewClientWithOpts(endpoint, &jsonrpc.RPCClientOpts{
HTTPClient: &http.Client{Timeout: rpcTimeout},
HTTPClient: &http.Client{Timeout: sdkrouter.RPCTimeout},
}),
endpoint: endpoint,
userID: userID,
Expand All @@ -74,7 +73,7 @@ func (c *Caller) CallRaw(rawQuery []byte) []byte {
func (c *Caller) Call(req *jsonrpc.RPCRequest) []byte {
r, err := c.call(req)
if err != nil {
monitor.CaptureException(err, map[string]string{"req": spew.Sdump(req), "response": fmt.Sprintf("%v", r)})
monitor.CaptureException(err, map[string]string{"request": spew.Sdump(req), "response": fmt.Sprintf("%v", r)})
logger.Log().Errorf("error calling lbrynet: %v, request: %s", err, spew.Sdump(req))
return marshalError(err)
}
Expand Down
2 changes: 2 additions & 0 deletions app/sdkrouter/sdkrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
ljsonrpc "github.com/lbryio/lbry.go/v2/extras/jsonrpc"
)

const RPCTimeout = 300 * time.Second

var logger = monitor.NewModuleLogger("sdkrouter")

func DisableLogger() { logger.Disable() } // for testing
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.2'

services:
lbrynet:
image: lbry/lbrynet-tv:cluster3
image: lbry/lbrynet-tv:latest
ports:
- "5581:5279"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewServer(address string, sdkRouter *sdkrouter.Router) *Server {
listener: &http.Server{
Addr: address,
Handler: r,
WriteTimeout: 32 * time.Second,
WriteTimeout: sdkrouter.RPCTimeout + 60*time.Second,
IdleTimeout: 0,
ReadHeaderTimeout: 10 * time.Second,
},
Expand Down

0 comments on commit 253e39b

Please sign in to comment.