frostfs-node/pkg/innerring/processors/container/handlers.go
Alex Vanin c4cdfe3ec2 [#7] Add container processor for inner ring
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:35 +03:00

28 lines
757 B
Go

package container
import (
"crypto/sha256"
"github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
containerEvent "github.com/nspcc-dev/neofs-node/pkg/morph/event/container"
"go.uber.org/zap"
)
func (cp *Processor) handlePut(ev event.Event) {
put := ev.(containerEvent.Put) // todo: check panic in production
id := sha256.Sum256(put.Container())
cp.log.Info("notification",
zap.String("type", "container put"),
zap.String("id", base58.Encode(id[:])))
// send event to the worker pool
err := cp.pool.Submit(func() { cp.processContainerPut(&put) })
if err != nil {
// todo: move into controlled degradation stage
cp.log.Warn("container processor worker pool drained",
zap.Int("capacity", cp.pool.Cap()))
}
}