Effect CommunityEC
Effect Communityโ€ข2y agoโ€ข
37 replies
RJ

Trouble understanding how to use `Pool`

I have a perhaps somewhat peculiar scenario in which I believe I need a resource pool, but I'm having trouble understanding how to use Pool properly.

There is an API which I need to interact with which has a pool of workers allocated for processing my requests. These workers process my requests as they come in, and if a request of mine comes in while all of the workers are busy, it will be put in a queue. However, this queue will not hold requests for long, so if I overwhelm it it will begin dropping requests (which I'd like to avoid).

In order to prevent that from happening, I'd like to emulate the pool used by this service and use this emulated pool to limit the number of active requests to <= the number of workers in the pool (I do know the number of workers in this service's pool).

I suspect that I can use Effect's Pool to do this, but I'm having trouble figuring out how, and I can't find many examples of it in use.

If it's not too much trouble for someone, a very simple example of how I might accomplish this sort of thing would probably be the most helpful for me.
Was this page helpful?