https://github.com/nwtgck/akka-stream-zstd
Zstandard compression for Akka Stream
https://github.com/nwtgck/akka-stream-zstd
akka akka-streams scala zstandard zstd
Last synced: 9 months ago
JSON representation
Zstandard compression for Akka Stream
- Host: GitHub
- URL: https://github.com/nwtgck/akka-stream-zstd
- Owner: nwtgck
- License: mit
- Created: 2018-07-24T05:27:44.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2019-01-12T01:24:09.000Z (over 7 years ago)
- Last Synced: 2024-10-11T15:11:30.109Z (over 1 year ago)
- Topics: akka, akka-streams, scala, zstandard, zstd
- Language: Scala
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# akka-stream-zstd
[](https://travis-ci.com/nwtgck/akka-stream-zstd) [](https://coveralls.io/github/nwtgck/akka-stream-zstd?branch=develop)
[Zstandard](https://facebook.github.io/zstd/) for [Akka Stream](https://doc.akka.io/docs/akka/2.5.5/scala/stream/index.html)
## Installation
Add the following lines to your `build.sbt`.
```scala
// Add dependency of `akka-stream-zstd.git` on GitHub
dependsOn(RootProject(uri("https://github.com/nwtgck/akka-stream-zstd.git#v0.1.5")))
```
## Example of compression
Here is an example to compress and store into a file
```scala
source
// Compress
.via(ZstdFlow.compress())
// Store to file
.runWith(FileIO.toPath(filePath))
```
[Full example](https://github.com/nwtgck/akka-stream-zstd-example/blob/965c98b708c0de22e8b256e24548d8cc87d1f33b/src/main/scala/Main.scala#L24-L29)
## Example of decompression
Here is an example to decompress from a stored file and convert into a `String`.
```scala
FileIO.fromPath(filePath)
// Decompress
.via(ZstdFlow.decompress())
// Concatenate into one ByteString
.runWith(Sink.fold(ByteString.empty)(_ ++ _))
// Convert ByteString to String
.map(_.utf8String)
```
[Full example](https://github.com/nwtgck/akka-stream-zstd-example/blob/965c98b708c0de22e8b256e24548d8cc87d1f33b/src/main/scala/Main.scala#L35-L42)
## Example repository
Here is a full example.
* [akka-stream-zstd-example](https://github.com/nwtgck/akka-stream-zstd-example)