Skip to content

Commit

Permalink
Remove unused chunk parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Sep 15, 2020
1 parent 98f252a commit 7bd554f
Showing 1 changed file with 13 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class HttpClientZioBackend private (
client: HttpClient,
closeClient: Boolean,
customizeRequest: HttpRequest => HttpRequest,
customEncodingHandler: EncodingHandler[BlockingZioStreams.BinaryStream],
chunkSize: Int
customEncodingHandler: EncodingHandler[BlockingZioStreams.BinaryStream]
) extends HttpClientAsyncBackend[
BlockingTask,
BlockingZioStreams,
Expand Down Expand Up @@ -84,65 +83,57 @@ class HttpClientZioBackend private (

object HttpClientZioBackend {

private val defaultChunkSize = 65536
type ZioEncodingHandler = EncodingHandler[BlockingZioStreams.BinaryStream]

private def apply(
client: HttpClient,
closeClient: Boolean,
customizeRequest: HttpRequest => HttpRequest,
customEncodingHandler: ZioEncodingHandler,
chunkSize: Int
customEncodingHandler: ZioEncodingHandler
): SttpBackend[BlockingTask, BlockingZioStreams with WebSockets] =
new FollowRedirectsBackend(
new HttpClientZioBackend(
client,
closeClient,
customizeRequest,
customEncodingHandler,
chunkSize
customEncodingHandler
)
)

def apply(
options: SttpBackendOptions = SttpBackendOptions.Default,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty,
chunkSize: Int = defaultChunkSize
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty
): Task[SttpBackend[BlockingTask, BlockingZioStreams with WebSockets]] =
Task.effect(
HttpClientZioBackend(
HttpClientBackend.defaultClient(options),
closeClient = true,
customizeRequest,
customEncodingHandler,
chunkSize
customEncodingHandler
)
)

def managed(
options: SttpBackendOptions = SttpBackendOptions.Default,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty,
chunkSize: Int = defaultChunkSize
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty
): ZManaged[Blocking, Throwable, SttpBackend[BlockingTask, BlockingZioStreams with WebSockets]] =
ZManaged.make(apply(options, customizeRequest, customEncodingHandler, chunkSize))(
ZManaged.make(apply(options, customizeRequest, customEncodingHandler))(
_.close().ignore
)

def layer(
options: SttpBackendOptions = SttpBackendOptions.Default,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty,
chunkSize: Int = defaultChunkSize
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty
): ZLayer[Blocking, Throwable, SttpClient] = {
ZLayer.fromManaged(
(for {
backend <- HttpClientZioBackend(
options,
customizeRequest,
customEncodingHandler,
chunkSize
customEncodingHandler
)
} yield backend).toManaged(_.close().ignore)
)
Expand All @@ -151,31 +142,27 @@ object HttpClientZioBackend {
def usingClient(
client: HttpClient,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty,
chunkSize: Int = defaultChunkSize
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty
): SttpBackend[BlockingTask, BlockingZioStreams with WebSockets] =
HttpClientZioBackend(
client,
closeClient = false,
customizeRequest,
customEncodingHandler,
chunkSize
customEncodingHandler
)

def layerUsingClient(
client: HttpClient,
customizeRequest: HttpRequest => HttpRequest = identity,
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty,
chunkSize: Int = defaultChunkSize
customEncodingHandler: ZioEncodingHandler = PartialFunction.empty
): ZLayer[Blocking, Throwable, SttpClient] = {
ZLayer.fromManaged(
ZManaged
.makeEffect(
usingClient(
client,
customizeRequest,
customEncodingHandler,
chunkSize
customEncodingHandler
)
)(_.close().ignore)
)
Expand Down

0 comments on commit 7bd554f

Please sign in to comment.