Skip to content

Commit

Permalink
Optimise zio.http.endpoint.Endpoint.implementHandler
Browse files Browse the repository at this point in the history
Replace `.map(..).catchAll(..)` with `.foldZIO`
  • Loading branch information
guizmaii committed Dec 5, 2024
1 parent 1f8ef1f commit 6a867e7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,10 @@ final case class Endpoint[PathInput, Input, Err, Output, Auth <: AuthType](
)
.getOrElse(defaultMediaTypes)
(endpoint.input ++ authCodec(endpoint.authType)).decodeRequest(request, config).orDie.flatMap { value =>
original(value).map(endpoint.output.encodeResponse(_, outputMediaTypes, config)).catchAll { error =>
ZIO.succeed(endpoint.error.encodeResponse(error, outputMediaTypes, config))
}
original(value).foldZIO(
success = output => Exit.succeed(endpoint.output.encodeResponse(output, outputMediaTypes, config)),
failure = error => Exit.succeed(endpoint.error.encodeResponse(error, outputMediaTypes, config)),
)
}
} -> condition
}
Expand Down

2 comments on commit 6a867e7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 : Performance Benchmarks (PlainTextBenchmarkServer)

concurrency: 256
requests/sec: 344607

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 : Performance Benchmarks (SimpleEffectBenchmarkServer)

concurrency: 256
requests/sec: 357037

Please sign in to comment.