Skip to content

Commit

Permalink
close resp body
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn-gif committed Sep 4, 2023
1 parent 1fe58ae commit d9f01eb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 14 deletions.
5 changes: 4 additions & 1 deletion cmd/http/oraclebuilder/utils/podhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (kh *PodHelper) RestartOracleFeeder(ctx context.Context, feederID string, o
//if err != nil {
// return err
//}
kh.waitPodDeleted(ctx, oracleconfig.Address, func() {
deleteerr := kh.waitPodDeleted(ctx, oracleconfig.Address, func() {
time.Sleep(1000 * time.Millisecond)
err = kh.CreateOracleFeeder(ctx, feederID, oracleconfig.Owner, oracleconfig.Address, oracleconfig.ChainID, strings.Join(oracleconfig.Symbols[:], ","), oracleconfig.FeederSelection, oracleconfig.BlockchainNode, oracleconfig.Frequency, oracleconfig.SleepSeconds, oracleconfig.DeviationPermille, oracleconfig.MandatoryFrequency)
if err != nil {
Expand All @@ -254,6 +254,9 @@ func (kh *PodHelper) RestartOracleFeeder(ctx context.Context, feederID string, o
}
log.Infof("Pod %s started\n", feederID)
})
if deleteerr != nil {
log.Infof("Pod %s delete err\n", deleteerr.Error())
}
log.Infof("Pod %s deleted\n", feederID)
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/dia/nft/nftTrade-scrapers/blurV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,12 @@ func (s *BlurV1Scraper) readNFTAttr(ctx context.Context, uri string) (map[string
return nil, err
}

defer resp.Body.Close()
defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()

if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/looksrare.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,12 @@ func (s *LooksRareScraper) readNFTAttr(ctx context.Context, uri string) (map[str
return nil, err
}

defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/opensea.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,12 @@ func (s *OpenSeaScraper) readNFTAttr(ctx context.Context, uri string) (map[strin
return nil, err
}

defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/openseaBayc.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,12 @@ func (s *OpenSeaBAYCScraper) readNFTAttr(ctx context.Context, uri string) (map[s
return nil, err
}

defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/openseaSeaport.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,12 @@ func (s *OpenSeaSeaportScraper) readNFTAttr(ctx context.Context, uri string) (ma
return nil, err
}

defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/nft/nftTrade-scrapers/tofunft.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,12 @@ func (s *TofuNFTScraper) readNFTAttr(ctx context.Context, uri string) (map[strin
return nil, err
}

defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return nil, errors.New("unable to read token attributes: " + resp.Status)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/dia/scraper/exchange-scrapers/BitmaxScraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,12 @@ func (s *BitMaxScraper) FetchAvailablePairs() (pairs []dia.ExchangePair, err err
log.Error("get symbols: ", err)
}

defer response.Body.Close()

defer func() {
if cerr := response.Body.Close(); cerr != nil {
// Handle the error from closing the response body
log.Println("Error closing response body:", cerr)
}
}()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Error("read symbols: ", err)
Expand Down

0 comments on commit d9f01eb

Please sign in to comment.