mcollina / fastq

Fast, in memory work queue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Request] Kill queue but execute drain function.

AoDev opened this issue · comments

commented

Hello, I wanted to ask to be able to execute the drain function on kill.

The reason is that the user might cancel the process because it's too long but still wants things to happen with the already processed tasks.

I could implement such thing on my side.
But, checking the kill function code,
I think it would be easier to simply be able to call:

queue.killAndDrain()
// whatever the final API would be

function killAndDrain () {
  queueHead = null
  queueTail = null
  self.drain()
  self.drain = noop
}

What do you think?

It seems a nice feature. Would you like to send a PR?

commented

PR Submitted. I am not familiar with tape, so I have just copied the kill test but check for the drain function to be called. Let me know if we should change anything.

commented

Closing this, it was implemented in #5 .