-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executor: decompress gzip paloyads before logging them (#3746)
* executor: decompress gzip paloyads before logging them * extend kfserving sample to include logger * refactor * further refactor
- Loading branch information
1 parent
f32ac46
commit 2e57a07
Showing
7 changed files
with
87 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package payload | ||
|
||
import ( | ||
"bytes" | ||
"compress/gzip" | ||
"io/ioutil" | ||
) | ||
|
||
func DecompressBytes(data []byte, contentEncoding string) ([]byte, error) { | ||
if contentEncoding != "gzip" { | ||
return data, nil | ||
} | ||
|
||
bytesReader := bytes.NewReader(data) | ||
gzipReader, err := gzip.NewReader(bytesReader) | ||
if err != nil { | ||
return nil, err | ||
} | ||
output, err := ioutil.ReadAll(gzipReader) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return output, nil | ||
} | ||
|
||
// Decompress payloads if Content-Encoding is set to gzip | ||
func DecompressSeldonPayload(msg SeldonPayload) ([]byte, error) { | ||
data, err := msg.GetBytes() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return DecompressBytes(data, msg.GetContentEncoding()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters