Skip to content

Commit

Permalink
!str akka#21395 move compression default values used in public API in…
Browse files Browse the repository at this point in the history
…to public place

Would it otherwise have even worked for non-akka users?
  • Loading branch information
jrudolph authored and ktoso committed Nov 21, 2016
1 parent 10e17ae commit 2c32a7c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ package akka.stream.impl.io.compression
import java.util.zip.Inflater

import akka.stream.Attributes
import akka.stream.impl.io.ByteStringParser
import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep }
import akka.util.ByteString

/** INTERNAL API */
private[akka] class DeflateDecompressor(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault)
private[akka] class DeflateDecompressor(maxBytesPerChunk: Int)
extends DeflateDecompressorBase(maxBytesPerChunk) {

override def createLogic(attr: Attributes) = new DecompressorParsingLogic {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep }
import akka.util.ByteString

/** INTERNAL API */
private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault)
private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int)
extends ByteStringParser[ByteString] {

abstract class DecompressorParsingLogic extends ParsingLogic {
Expand Down Expand Up @@ -45,6 +45,4 @@ private[akka] abstract class DeflateDecompressorBase(maxBytesPerChunk: Int = Def
}

/** INTERNAL API */
private[akka] object DeflateDecompressorBase {
final val MaxBytesPerChunkDefault = 64 * 1024
}
private[akka] object DeflateDecompressorBase
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import akka.stream.impl.io.ByteStringParser.{ ParseResult, ParseStep }
import akka.util.ByteString

/** INTERNAL API */
private[akka] class GzipDecompressor(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault)
private[akka] class GzipDecompressor(maxBytesPerChunk: Int)
extends DeflateDecompressorBase(maxBytesPerChunk) {

override def createLogic(attr: Attributes) = new DecompressorParsingLogic {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import akka.stream.impl.io.compression._
import akka.util.ByteString

object Compression {
final val MaxBytesPerChunkDefault = 64 * 1024

/**
* Creates a flow that gzip-compresses a stream of ByteStrings. Note that the compressor
* will SYNC_FLUSH after every [[ByteString]] so that it is guaranteed that every [[ByteString]]
Expand All @@ -24,7 +26,7 @@ object Compression {
*
* @param maxBytesPerChunk Maximum length of an output [[ByteString]] chunk.
*/
def gunzip(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] =
def gunzip(maxBytesPerChunk: Int = MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] =
Flow[ByteString].via(new GzipDecompressor(maxBytesPerChunk))
.named("gunzip")

Expand All @@ -44,7 +46,7 @@ object Compression {
*
* @param maxBytesPerChunk Maximum length of an output [[ByteString]] chunk.
*/
def inflate(maxBytesPerChunk: Int = DeflateDecompressorBase.MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] =
def inflate(maxBytesPerChunk: Int = MaxBytesPerChunkDefault): Flow[ByteString, ByteString, NotUsed] =
Flow[ByteString].via(new DeflateDecompressor(maxBytesPerChunk))
.named("inflate")
}

0 comments on commit 2c32a7c

Please sign in to comment.