forked from TrueCloudLab/frostfs-node
[#452] innerring: Add reputation processor
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
335b31206f
commit
09e4479d44
3 changed files with 174 additions and 0 deletions
31
pkg/innerring/processors/reputation/handlers.go
Normal file
31
pkg/innerring/processors/reputation/handlers.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package reputation
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
reputationEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/reputation"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (rp *Processor) handlePutReputation(ev event.Event) {
|
||||
put := ev.(reputationEvent.Put)
|
||||
rp.log.Info("notification",
|
||||
zap.String("type", "reputation put"),
|
||||
zap.String("peer_id", hex.EncodeToString(put.PeerID().Bytes())))
|
||||
|
||||
// send event to the worker pool
|
||||
|
||||
err := rp.pool.Submit(func() {
|
||||
rp.processPut(
|
||||
put.Epoch(),
|
||||
put.PeerID(),
|
||||
put.Value(),
|
||||
)
|
||||
})
|
||||
if err != nil {
|
||||
// there system can be moved into controlled degradation stage
|
||||
rp.log.Warn("reputation worker pool drained",
|
||||
zap.Int("capacity", rp.pool.Cap()))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue