Airat Arifullin
b543569c3f
* Register GRPC services for both neo.fs.v2 and frost.fs namespaces * Use this temporary solution until all nodes are updated Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"strings"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/balance"
|
|
accountingTransportGRPC "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/transport/accounting/grpc"
|
|
accountingService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/accounting"
|
|
accounting "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/accounting/morph"
|
|
accountingGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/grpc"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func initAccountingService(ctx context.Context, c *cfg) {
|
|
c.initMorphComponents(ctx)
|
|
|
|
balanceMorphWrapper, err := balance.NewFromMorph(c.cfgMorph.client, c.cfgAccounting.scriptHash, 0)
|
|
fatalOnErr(err)
|
|
|
|
server := accountingTransportGRPC.New(
|
|
accountingService.NewSignService(
|
|
&c.key.PrivateKey,
|
|
accountingService.NewExecutionService(
|
|
accounting.NewExecutor(balanceMorphWrapper),
|
|
c.respSvc,
|
|
),
|
|
),
|
|
)
|
|
|
|
c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) {
|
|
accountingGRPC.RegisterAccountingServiceServer(s, server)
|
|
|
|
// TODO(@aarifullin): #1487 remove the dual service support.
|
|
s.RegisterService(frostFSServiceDesc(accountingGRPC.AccountingService_ServiceDesc), server)
|
|
})
|
|
}
|
|
|
|
// frostFSServiceDesc creates a service descriptor with the new namespace for dual service support.
|
|
func frostFSServiceDesc(sd grpc.ServiceDesc) *grpc.ServiceDesc {
|
|
sdLegacy := new(grpc.ServiceDesc)
|
|
*sdLegacy = sd
|
|
|
|
const (
|
|
legacyNamespace = "neo.fs.v2"
|
|
apemanagerLegacyNamespace = "frostfs.v2"
|
|
newNamespace = "frost.fs"
|
|
)
|
|
|
|
if strings.HasPrefix(sd.ServiceName, legacyNamespace) {
|
|
sdLegacy.ServiceName = strings.ReplaceAll(sd.ServiceName, legacyNamespace, newNamespace)
|
|
} else if strings.HasPrefix(sd.ServiceName, apemanagerLegacyNamespace) {
|
|
sdLegacy.ServiceName = strings.ReplaceAll(sd.ServiceName, apemanagerLegacyNamespace, newNamespace)
|
|
}
|
|
return sdLegacy
|
|
}
|