forked from TrueCloudLab/frostfs-node
[#476] reputation: Make reputation report async
Add handler closure over worker pool in the event package. Add `addNewEpochAsyncNotificationHandler` function that uses that closure. Pass the reputation report handler to worker pool via using that function. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
7cd4e409eb
commit
72699b4c26
3 changed files with 43 additions and 8 deletions
|
@ -1,6 +1,10 @@
|
|||
package event
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/util"
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
util2 "github.com/nspcc-dev/neofs-node/pkg/util"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type scriptHashValue struct {
|
||||
hash util.Uint160
|
||||
|
@ -34,3 +38,18 @@ func (s *typeValue) SetType(v Type) {
|
|||
func (s typeValue) GetType() Type {
|
||||
return s.typ
|
||||
}
|
||||
|
||||
// WorkerPoolHandler sets closure over worker pool w with passed handler h.
|
||||
func WorkerPoolHandler(w util2.WorkerPool, h Handler, log *zap.Logger) Handler {
|
||||
return func(e Event) {
|
||||
err := w.Submit(func() {
|
||||
h(e)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.Warn("could not Submit handler to worker pool",
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue