frostfs-node/pkg/network/transport/object/grpc/implementations.go
Stanislav Bogatyrev b7b5079934 Add Inner Ring code
2020-07-24 17:07:37 +03:00

32 lines
737 B
Go

package object
import (
"context"
"github.com/multiformats/go-multiaddr"
"github.com/nspcc-dev/neofs-api-go/object"
"github.com/nspcc-dev/neofs-node/pkg/network/peers"
"github.com/pkg/errors"
)
type (
remoteService struct {
ps peers.Interface
}
)
// NewRemoteService is a remote service controller's constructor.
func NewRemoteService(ps peers.Interface) RemoteService {
return &remoteService{
ps: ps,
}
}
func (rs remoteService) Remote(ctx context.Context, addr multiaddr.Multiaddr) (object.ServiceClient, error) {
con, err := rs.ps.GRPCConnection(ctx, addr)
if err != nil {
return nil, errors.Wrapf(err, "remoteService.Remote failed on GRPCConnection to %s", addr)
}
return object.NewServiceClient(con), nil
}