java.lang.Object
org.apache.pekko.http.scaladsl.coding.Zstd
All Implemented Interfaces:
Coder, Decoder, Encoder

public final class Zstd extends Object implements Coder
INTERNAL API

An encoder and decoder for the HTTP 'zstd' encoding (RFC 8878), use Coders.Zstd to get one.

zstd is implemented by pekko-stream, which needs the optional com.github.luben:zstd-jni dependency on the classpath.

RFC 9659 limits the window of the 'zstd' content coding to 8 MB: encoders must not need a larger window, and decoders only have to support up to that. So the encoder caps the window of the compression levels that would use a larger one, and the decoder rejects frames that need more than 2^windowLogMax bytes.

param: windowLogMax the log2 of the largest window the decoder accepts, 0 uses the limit of libzstd (128 MB)

  • Constructor Details

    • Zstd

      public Zstd(int compressionLevel, scala.Function1<HttpMessage,Object> messageFilter, int maxBytesPerChunk, int windowLogMax)
  • Method Details

    • DefaultCompressionLevel

      public static int DefaultCompressionLevel()
    • MaxWindowLog

      public static int MaxWindowLog()
      The 8 MB window that RFC 9659 allows for the 'zstd' content coding
    • DefaultWindowLogMax

      public static int DefaultWindowLogMax()
    • windowLogFor

      public static int windowLogFor(int compressionLevel)
    • Default

      public static Zstd Default()
    • messageFilter

      public scala.Function1<HttpMessage,Object> messageFilter()
      Specified by:
      messageFilter in interface Encoder
    • maxBytesPerChunk

      public int maxBytesPerChunk()
      Specified by:
      maxBytesPerChunk in interface Decoder
    • encoding

      public HttpEncoding encoding()
      Specified by:
      encoding in interface Decoder
      Specified by:
      encoding in interface Encoder
    • newCompressor

      public Compressor newCompressor()
      Specified by:
      newCompressor in interface Encoder
    • withMaxBytesPerChunk

      public Decoder withMaxBytesPerChunk(int newMaxBytesPerChunk)
      Specified by:
      withMaxBytesPerChunk in interface Decoder
    • decoderFlow

      public org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString,org.apache.pekko.NotUsed> decoderFlow()
      Specified by:
      decoderFlow in interface Decoder
    • withLevel

      public Zstd withLevel(int level)