diff options
author | Valery Piashchynski <[email protected]> | 2021-06-08 12:24:04 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-08 12:24:04 +0300 |
commit | 49ce25e80ba99ac91bce7ea2b9b632de53e07c0d (patch) | |
tree | c6ecace041bdb70754825123c60d78cd43d84dd8 | |
parent | f02fcd10ab8104b69581bbe2c3e1fd80a47c4316 (diff) | |
parent | 6fb801dd3cde33deb5514b40cabae2b572d5c404 (diff) |
#710 feat(metrics): make `workers_hanler` listener events async
#710 feat(metrics): make `workers_hanler` listener events async
-rw-r--r-- | pkg/worker_handler/handler.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/worker_handler/handler.go b/pkg/worker_handler/handler.go index 2534a331..fc03563b 100644 --- a/pkg/worker_handler/handler.go +++ b/pkg/worker_handler/handler.go @@ -192,8 +192,13 @@ func (h *Handler) handleResponse(req *Request, resp *Response, start time.Time) // sendEvent invokes event handler if any. func (h *Handler) sendEvent(event interface{}) { if h.lsn != nil { - for _, l := range h.lsn { - l(event) + for i := range h.lsn { + // do not block the pipeline + // TODO not a good approach, redesign event bus + i := i + go func() { + h.lsn[i](event) + }() } } } |