jrudolph commented on code in PR #2409:
URL: https://github.com/apache/pekko/pull/2409#discussion_r2472735096


##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Compression.scala:
##########
@@ -85,4 +87,28 @@ object Compression {
    */
   def inflate(maxBytesPerChunk: Int, nowrap: Boolean): Flow[ByteString, 
ByteString, NotUsed] =
     Flow[ByteString].via(new DeflateDecompressor(maxBytesPerChunk, 
nowrap)).named("inflate")
+
+  /**
+   * @since 2.0.0
+   */
+  def zstd: Flow[ByteString, ByteString, NotUsed] = 
zstd(Zstd.defaultCompressionLevel())
+
+  /**
+   * Same as [[zstd]] with a custom level and an optional dictionary.
+   * @param level The compression level, must be greater or equal to 
[[Zstd.minCompressionLevel]] and less than or equal
+   *              to [[Zstd.maxCompressionLevel]]
+   * @param dictionary An optional dictionary that can be used for compression
+   * @since 2.0.0
+   */
+  def zstd(level: Int, dictionary: Option[ZstdDictCompress] = None): 
Flow[ByteString, ByteString, NotUsed] = {
+    require(level <= Zstd.maxCompressionLevel() && level >= 
Zstd.minCompressionLevel())
+    CompressionUtils.compressorFlow(() => new ZstdCompressor(level, 
dictionary))
+  }
+
+  /**
+   * @since 2.0.0
+   */
+  def zstdDecompress(maxBytesPerChunk: Int = MaxBytesPerChunkDefault): 
Flow[ByteString, ByteString, NotUsed] =
+    Flow[ByteString].via(new 
ZstdDecompressor(maxBytesPerChunk)).named("zstdDecompress")

Review Comment:
   One difference is that zlib is distributed differently and already part of 
the JDK while zstd-jni might bring extra weight that not everyone is interested 
in. The full jar including binaries for all platforms is >7MB. Whether that is 
significant or not is a different question but it goes somewhat against the 
usual idea to keep pekko-stream reasonably minimal and add stuff like this to 
the connectors (which probably does not work if we want to depend on it from 
http). So, I'd also slightly favor having an extra module at least in pekko 
core.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to