49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package governance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event/rolemanagement"
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (gp *Processor) HandleAlphabetSync(ctx context.Context, e event.Event) {
|
|
var (
|
|
typ string
|
|
hash util.Uint256
|
|
)
|
|
|
|
switch et := e.(type) {
|
|
case Sync:
|
|
typ = "sync"
|
|
hash = et.TxHash()
|
|
case rolemanagement.Designate:
|
|
if et.Role != noderoles.NeoFSAlphabet {
|
|
return
|
|
}
|
|
|
|
typ = native.DesignationEventName
|
|
hash = et.TxHash
|
|
default:
|
|
return
|
|
}
|
|
|
|
gp.log.Info(ctx, logs.GovernanceNewEvent, zap.String("type", typ))
|
|
|
|
// send event to the worker pool
|
|
|
|
err := processors.SubmitEvent(gp.pool, gp.metrics, "alphabet_sync", func() bool {
|
|
return gp.processAlphabetSync(ctx, hash)
|
|
})
|
|
if err != nil {
|
|
// there system can be moved into controlled degradation stage
|
|
gp.log.Warn(ctx, logs.GovernanceGovernanceWorkerPoolDrained,
|
|
zap.Int("capacity", gp.pool.Cap()))
|
|
}
|
|
}
|