summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-08 12:24:04 +0300
committerGitHub <[email protected]>2021-06-08 12:24:04 +0300
commit49ce25e80ba99ac91bce7ea2b9b632de53e07c0d (patch)
treec6ecace041bdb70754825123c60d78cd43d84dd8
parentf02fcd10ab8104b69581bbe2c3e1fd80a47c4316 (diff)
parent6fb801dd3cde33deb5514b40cabae2b572d5c404 (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.go9
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)
+ }()
}
}
}