2020-10-22 11:06:25 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/netmap"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util/response"
|
2020-10-22 11:06:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type responseService struct {
|
|
|
|
respSvc *response.Service
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
svc Server
|
2020-10-22 11:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewResponseService returns netmap service instance that passes internal service
|
|
|
|
// call to response service.
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewResponseService(nmSvc Server, respSvc *response.Service) Server {
|
2020-10-22 11:06:25 +00:00
|
|
|
return &responseService{
|
|
|
|
respSvc: respSvc,
|
|
|
|
svc: nmSvc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
|
|
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2020-10-22 11:06:25 +00:00
|
|
|
return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*netmap.LocalNodeInfoResponse), nil
|
|
|
|
}
|
2021-02-19 08:01:37 +00:00
|
|
|
|
|
|
|
func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) {
|
|
|
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2021-02-19 08:01:37 +00:00
|
|
|
return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*netmap.NetworkInfoResponse), nil
|
|
|
|
}
|
2022-09-17 12:37:01 +00:00
|
|
|
|
|
|
|
func (s *responseService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
|
|
|
|
resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
|
2023-02-21 11:42:45 +00:00
|
|
|
func(ctx context.Context, req any) (util.ResponseMessage, error) {
|
2022-09-17 12:37:01 +00:00
|
|
|
return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest))
|
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*netmap.SnapshotResponse), nil
|
|
|
|
}
|