Increase use of pointers to improve memory usage. Currently uses around 16GB RAM.
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// Downloads NROD Data over HTTP from the given URL, extracted data is returned
|
||||
func NrodDownload(url string, cfg *helpers.Configuration) ([]byte, error) {
|
||||
func NrodDownload(url string, cfg *helpers.Configuration) (*[]byte, error) {
|
||||
log.Msg.Debug("Fetching NROD data", zap.String("Request URL", url))
|
||||
client := http.Client{
|
||||
Timeout: time.Second * 10,
|
||||
@@ -49,7 +49,7 @@ func NrodDownload(url string, cfg *helpers.Configuration) ([]byte, error) {
|
||||
}
|
||||
|
||||
// Extracts GZIP Data from an HTTP Response and returns the decompresses data as a byte array
|
||||
func nrodExtract(resp http.Response) ([]byte, error) {
|
||||
func nrodExtract(resp http.Response) (*[]byte, error) {
|
||||
log.Msg.Debug("Extracting HTTP Response Data")
|
||||
gzReader, err := gzip.NewReader(resp.Body)
|
||||
if err != nil {
|
||||
@@ -59,7 +59,7 @@ func nrodExtract(resp http.Response) ([]byte, error) {
|
||||
log.Msg.Error("Unable to read response body")
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
defer gzReader.Close()
|
||||
@@ -70,5 +70,5 @@ func nrodExtract(resp http.Response) ([]byte, error) {
|
||||
log.Msg.Error("Failed to read GZIPped data", zap.Error(err))
|
||||
}
|
||||
|
||||
return extractedData, nil
|
||||
return &extractedData, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user