Skip to content

Commit

Permalink
Use eager ZIO/ZQuery constructors as much as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
kyri-petrou committed Jun 23, 2024
1 parent c0ac37c commit 28ae855
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 349 deletions.
14 changes: 8 additions & 6 deletions adapters/quick/src/main/scala/caliban/QuickRequestHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ final private class QuickRequestHandler[R](
new QuickRequestHandler[R & R1](interpreter, config)

def handleHttpRequest(request: Request)(implicit trace: Trace): URIO[R, Response] =
transformHttpRequest(request)
.flatMap(executeRequest(request.method, _))
.foldZIO(
Exit.succeed,
resp => Exit.succeed(transformResponse(request, resp))
)
ZIO.suspendSucceed { // Suspending to ensure that all the CPU work we're about to do happens in the ZIO thread pool
transformHttpRequest(request)
.flatMap(executeRequest(request.method, _))
.foldZIO(
Exit.succeed,
resp => Exit.succeed(transformResponse(request, resp))
)
}

def handleUploadRequest(request: Request)(implicit trace: Trace): URIO[R, Response] =
transformUploadRequest(request).flatMap { case (req, fileHandle) =>
Expand Down
Loading

0 comments on commit 28ae855

Please sign in to comment.