GithubHelp home page GithubHelp logo

Comments (5)

t3hnar avatar t3hnar commented on June 16, 2024 1

all client fibers waiting for a consumer will get an error.

if there are no other consumers in the pool - all get an error, but attempts after - will initiate allocation of a new consumers.

If maxSize > 1, only one attempt will fail.

you can implement retry on the level of passed resource, we don't need to encode this into the pool.

if (entries.isEmpty) {

means maxSize=1

from resource-pool.

edubrovski avatar edubrovski commented on June 16, 2024
  1. Something I don't understand is why do we count in tailRecM, for example
0.tailRecM { count =>
...
...
(count + 1).asLeft[Unit].pure[F]

Is this for debugging? I would just do

().tailRecM { _ =>
  ().asLeft[Unit].pure[F]
}

from resource-pool.

t3hnar avatar t3hnar commented on June 16, 2024

could be useful for debugging, and in short it does not provide more overhead comparing to what you propose :)

also it's nice when type differs from a happy path

from resource-pool.

edubrovski avatar edubrovski commented on June 16, 2024

What happens if we fail to allocate the resource and there are tasks (Deferreds) in the queue?

if (entries.isEmpty) {
  state.stage match {
    case stage: State.Allocated.Stage.Free =>
      apply(stage) { ().pure[F] }
    case stage: State.Allocated.Stage.Busy =>
      apply {
        State.Allocated.Stage.free(List.empty)
      } {
        stage
          .tasks
          .foldMapM { task =>
            task
              .complete(a.asLeft)
              .void
          }
      }
  }
} else {
  apply(stage) { ().pure[F] }
}

Looks like we complete all Deferreds with an error. What if there's just a temporary glitch? For example, when a KafkaConsumer gets created it tries to establish a connection to the broker. If there's a temporary network problem and one allocation fails because of it, all client fibers waiting for a consumer will get an error.

Shouldn't we retry allocation to avoid such situation?

from resource-pool.

edubrovski avatar edubrovski commented on June 16, 2024

Thanks for explanations! I couldn't find any bugs in the code. I've reviewed roughly half of it (I didn't review parts of code related to graceful shutdown).

from resource-pool.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.