0chain / gosdk

A client SDK in Go to interface the blockchain and storage platform, and other smart contracts
MIT License
32 stars 29 forks source link

Reuse clients and transports for greater efficiency #103

Closed Sriep closed 3 years ago

Sriep commented 3 years ago

Quote from http godoc https://golang.org/pkg/net/http/

Clients and Transports are safe for concurrent use by multiple goroutines
 and for efficiency should only be created once and re-used.

Currently, we make a new client and transport for every http.Client.Do request. https://github.com/0chain/gosdk/pull/65 changed this for one case, we should do the same elsewhere.

It helps with unit tests as well.

Sriep commented 3 years ago

Fixed in https://github.com/0chain/gosdk/pull/111 and https://github.com/0chain/gosdk/pull/65/files