forked from TrueCloudLab/frostfs-http-gw
[#232] Use contract to get container info
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
This commit is contained in:
parent
dbb1bcad00
commit
96a22d98f2
13 changed files with 229 additions and 44 deletions
|
@ -22,6 +22,8 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/handler/middleware"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/logs"
|
||||
internalnet "git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/net"
|
||||
containerClient "git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/service/contracts/container"
|
||||
contractsUtil "git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/service/contracts/util"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/service/frostfs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/internal/templates"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/metrics"
|
||||
|
@ -39,6 +41,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/input"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
|
@ -276,6 +279,14 @@ func (a *app) initContainers(ctx context.Context) {
|
|||
a.corsCnrID = *corsCnrID
|
||||
}
|
||||
|
||||
func (a *app) initRPCClient(ctx context.Context) *rpcclient.Client {
|
||||
rpcCli, err := rpcclient.New(ctx, a.config().GetString(cfgRPCEndpoint), rpcclient.Options{})
|
||||
if err != nil {
|
||||
a.log.Fatal(logs.InitRPCClientFailed, zap.Error(err), logs.TagField(logs.TagApp))
|
||||
}
|
||||
return rpcCli
|
||||
}
|
||||
|
||||
func (a *app) initAppSettings(lc *logLevelConfig) {
|
||||
a.settings = &appSettings{
|
||||
reconnectInterval: fetchReconnectInterval(a.config()),
|
||||
|
@ -750,7 +761,22 @@ func (a *app) stopServices() {
|
|||
}
|
||||
|
||||
func (a *app) configureRouter(workerPool *ants.Pool) {
|
||||
a.handle = handler.New(a.AppParams(), a.settings, tree.NewTree(frostfs.NewPoolWrapper(a.treePool), a.log), workerPool)
|
||||
rpcCli := a.initRPCClient(a.ctx)
|
||||
cnrContractName := a.config().GetString(cfgContractsContainerName)
|
||||
rpcEndpoint := a.config().GetString(cfgRPCEndpoint)
|
||||
cnrAddr, err := contractsUtil.ResolveContractHash(cnrContractName, rpcEndpoint)
|
||||
if err != nil {
|
||||
a.log.Fatal(logs.FailedToResolveContractHash, zap.Error(err), logs.TagField(logs.TagApp))
|
||||
}
|
||||
cnrClient, err := containerClient.New(containerClient.Config{
|
||||
ContractHash: cnrAddr,
|
||||
Key: a.key,
|
||||
RPCClient: rpcCli,
|
||||
})
|
||||
if err != nil {
|
||||
a.log.Fatal(logs.InitContainerContractFailed, zap.Error(err), logs.TagField(logs.TagApp))
|
||||
}
|
||||
a.handle = handler.New(a.AppParams(), a.settings, tree.NewTree(frostfs.NewPoolWrapper(a.treePool), a.log), cnrClient, workerPool)
|
||||
|
||||
r := router.New()
|
||||
r.RedirectTrailingSlash = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue