[#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 <carpawell@nspcc.ru>
This commit is contained in:
parent
72699b4c26
commit
91e0f4b370
1 changed files with 14 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue