kinsumer icon indicating copy to clipboard operation
kinsumer copied to clipboard

Calling Stop on a stopped consumer blocks

Open Sytten opened this issue 6 years ago • 3 comments

The title says pretty much all. The fix is not obvious though since it is using a blocking channel internally.

Sytten avatar Jun 27 '19 01:06 Sytten

Kinsumer is designed to be called from a single go routine, so you shouldn't have to call Stop() on a stopped consumer. That said, can you describe your use case some more, maybe I can update the library to handle your use case.

garethlewin avatar Jun 27 '19 01:06 garethlewin

The lib doesn't accept a Context, so it is somewhat hard to do a graceful shutdown. I ended up doing this:

go func() {
		select {
		case <-ctx.Done():
			k.Stop()
		}
	}()

But I also had a defer k.Stop() and it was blocking the shutdown.

Sytten avatar Jun 27 '19 15:06 Sytten

I guess the best way to fix this problem would be to accept a context so we can cancel the job.

Sytten avatar Jul 01 '19 15:07 Sytten