keypool icon indicating copy to clipboard operation
keypool copied to clipboard

Add a `fairness` parameter

Open samspills opened this issue 1 year ago • 0 comments

KeyPool and Pool now support a fairness parameter that controls how incoming requests are handled. When fairness is true requests are served in FIFO order, and when fairness is false requests are served in LIFO order.

The default value here is true, this is the opposite of commons-pool2 but it maintains consistency for people using keypool so I think it's the correct choice.

The behaviour switch is handled by a custom semaphore that we're using now, instead of the existing cats-effect semaphore. That semaphore has a BackingQueue that can switch behaviour between FIFO and LIFO (this is toggled using the fairness parameter)

samspills avatar Jul 31 '24 18:07 samspills