From 2263172a8459e07523db95ce186b5aba7a179fa6 Mon Sep 17 00:00:00 2001 From: Dmitry Krylov Date: Mon, 3 Jan 2022 21:25:22 +0300 Subject: [PATCH] Added graceful stop for worker --- worker/worker.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/worker/worker.go b/worker/worker.go index 7ca1389..53c4869 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -219,6 +219,15 @@ func (worker *Worker) customeHandler(inpack *inPack) { } } +// Stop serving +func (worker *Worker) Stop() { + worker.Lock() + defer worker.Unlock() + if worker.running == true { + close(worker.in) + } +} + // Close connection and exit main loop func (worker *Worker) Close() { worker.Lock()