Skip to content

Commit

Permalink
added new method to set maxConns limit for jsonrpc transport (umbracl…
Browse files Browse the repository at this point in the history
  • Loading branch information
munna0908 authored Dec 16, 2021
1 parent f99eda2 commit 58e3410
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jsonrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ func (c *Client) Close() error {
func (c *Client) Call(method string, out interface{}, params ...interface{}) error {
return c.transport.Call(method, out, params...)
}

// SetMaxConnsLimit sets the maximum number of connections that can be established with a host
func (c *Client) SetMaxConnsLimit(count int) {
c.transport.SetMaxConnsPerHost(count)
}
5 changes: 5 additions & 0 deletions jsonrpc/transport/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ func (h *HTTP) Call(method string, out interface{}, params ...interface{}) error
}
return nil
}

// SetMaxConnsPerHost sets the maximum number of connections that can be established with a host
func (h *HTTP) SetMaxConnsPerHost(count int) {
h.client.MaxConnsPerHost = count
}
3 changes: 3 additions & 0 deletions jsonrpc/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ type Transport interface {
// Call makes a jsonrpc request
Call(method string, out interface{}, params ...interface{}) error

// SetMaxConnsPerHost sets the maximum number of connections that can be established with a host
SetMaxConnsPerHost(count int)

// Close closes the transport connection if necessary
Close() error
}
Expand Down
4 changes: 4 additions & 0 deletions jsonrpc/transport/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ func (s *stream) Subscribe(method string, callback func(b []byte)) (func() error
return cancel, nil
}

// SetMaxConnsPerHost implements the transport interface
func (s *stream) SetMaxConnsPerHost(count int) {
}

type websocketCodec struct {
conn *websocket.Conn
}
Expand Down

0 comments on commit 58e3410

Please sign in to comment.