2020-07-24 13:54:03 +00:00
|
|
|
package neofs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
|
|
|
neofsEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/neofs"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (np *Processor) handleDeposit(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
deposit := ev.(neofsEvent.Deposit)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "deposit"),
|
|
|
|
zap.String("id", hex.EncodeToString(deposit.ID())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processDeposit(&deposit) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Warn("neofs processor worker pool drained",
|
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (np *Processor) handleWithdraw(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
withdraw := ev.(neofsEvent.Withdraw)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "withdraw"),
|
|
|
|
zap.String("id", hex.EncodeToString(withdraw.ID())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processWithdraw(&withdraw) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Warn("neofs processor worker pool drained",
|
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (np *Processor) handleCheque(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
cheque := ev.(neofsEvent.Cheque)
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "cheque"),
|
|
|
|
zap.String("id", hex.EncodeToString(cheque.ID())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processCheque(&cheque) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-07-24 13:54:03 +00:00
|
|
|
np.log.Warn("neofs processor worker pool drained",
|
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|
2020-09-08 09:01:38 +00:00
|
|
|
|
|
|
|
func (np *Processor) handleConfig(ev event.Event) {
|
2020-09-08 09:09:08 +00:00
|
|
|
cfg := ev.(neofsEvent.Config)
|
2020-09-08 09:01:38 +00:00
|
|
|
np.log.Info("notification",
|
|
|
|
zap.String("type", "set config"),
|
|
|
|
zap.String("key", hex.EncodeToString(cfg.Key())),
|
|
|
|
zap.String("value", hex.EncodeToString(cfg.Value())))
|
|
|
|
|
|
|
|
// send event to the worker pool
|
|
|
|
|
|
|
|
err := np.pool.Submit(func() { np.processConfig(&cfg) })
|
|
|
|
if err != nil {
|
2020-09-08 09:09:08 +00:00
|
|
|
// there system can be moved into controlled degradation stage
|
2020-09-08 09:01:38 +00:00
|
|
|
np.log.Warn("neofs processor worker pool drained",
|
|
|
|
zap.Int("capacity", np.pool.Cap()))
|
|
|
|
}
|
|
|
|
}
|