From 91e0f4b370725fa1dcd0abf906c64a72c1c24a36 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 14 Apr 2021 17:31:49 +0300 Subject: [PATCH] [#476] cmd/container: Add async handlers Add `addContainerAsyncNotificationHandler` func that passed handler to container's worker pool similar to how it is done in reputation handlers. Signed-off-by: Pavel Karpy --- cmd/neofs-node/container.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 0155086b..632e445c 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -138,6 +138,7 @@ func initContainerService(c *cfg) { ) } +// addContainerNotificationHandler adds handler that will be executed synchronously func addContainerNotificationHandler(c *cfg, sTyp string, h event.Handler) { typ := event.TypeFromString(sTyp) @@ -148,6 +149,19 @@ func addContainerNotificationHandler(c *cfg, sTyp string, h event.Handler) { c.cfgContainer.subscribers[typ] = append(c.cfgContainer.subscribers[typ], h) } +// addContainerAsyncNotificationHandler adds handler that will be executed asynchronously via container workerPool +func addContainerAsyncNotificationHandler(c *cfg, sTyp string, h event.Handler) { + addContainerNotificationHandler( + c, + sTyp, + event.WorkerPoolHandler( + c.cfgContainer.workerPool, + h, + c.log, + ), + ) +} + func setContainerNotificationParser(c *cfg, sTyp string, p event.Parser) { typ := event.TypeFromString(sTyp)