This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The github.com/DataDog/zstd library wraps a c library, so it requires cgo to compile. Add zstd wrapper funcs to sarama and put the zstd import behind a build flag requiring cgo. Without cgo, the wrapper funcs return an error saying zstd doesn't work without cgo.
- Loading branch information
Muir Manders
committed
Oct 2, 2018
1 parent
1a7ecd8
commit 3dd2f63
Showing
4 changed files
with
34 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// +build cgo | ||
|
||
package sarama | ||
|
||
import "github.com/DataDog/zstd" | ||
|
||
func zstdDecompress(dst, src []byte) ([]byte, error) { | ||
return zstd.Decompress(dst, src) | ||
} | ||
|
||
func zstdCompressLevel(dst, src []byte, level int) ([]byte, error) { | ||
return zstd.CompressLevel(dst, src, level) | ||
} |
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,17 @@ | ||
// +build !cgo | ||
|
||
package sarama | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
var errZstdCgo = errors.New("zstd compression requires building with cgo enabled") | ||
|
||
func zstdDecompress(dst, src []byte) ([]byte, error) { | ||
return nil, errZstdCgo | ||
} | ||
|
||
func zstdCompressLevel(dst, src []byte, level int) ([]byte, error) { | ||
return nil, errZstdCgo | ||
} |