elastic4s icon indicating copy to clipboard operation
elastic4s copied to clipboard

Cats Effect 2 executor doesn't shift back to the compute pool

Open pjurczenko opened this issue 3 years ago • 5 comments

The current implementation of Cats Effect 2 executor relies solely on Async.async method, which doesn't shift the execution back to the compute pool. This means that operations subsequent to the ElasticSearch queries will be performed on the dispatcher threads used for the non-blocking I/O, which is definitely undesirable. This is how the executor could look like to prevent this:

import cats.syntax.apply._

class CatsEffectExecutor[F[_]: Async: ContextShift] extends Executor[F] {
  override def exec(client: HttpClient, request: ElasticRequest): F[HttpResponse] =
    Async[F].async(cb => client.send(request, cb)) <* ContextShift[F].shift
}

However, such a change would be breaking the binary compatibility.

@sksamuel how do you approach such breaking changes in the elastic4s releases?

pjurczenko avatar Jun 06 '21 11:06 pjurczenko

We can do this for the 8.0 release which will contain other breaking changes.

sksamuel avatar Aug 01 '21 18:08 sksamuel

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 01 '21 06:10 stale[bot]

This is still relevant

github-sebastien-boulet avatar Oct 04 '21 12:10 github-sebastien-boulet