[#263] v2: Support new rpc library

Implement `message.Message` interface on all structures and use new methods
for conversion instead of functions. make `Unmarshal` and JSON methods to
use encoding functions from `message` library. Remove all per-service
clients and implement `rpc` library of the functions which execute NeoFS API
RPC through new RPC client. Remove no longer used gRPC per-service clients.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-03-12 15:57:23 +03:00 committed by Alex Vanin
parent 30c6ca0714
commit 1031f3122e
102 changed files with 7554 additions and 12298 deletions

View file

@ -1,46 +1,22 @@
package container
import (
"github.com/nspcc-dev/neofs-api-go/rpc/message"
container "github.com/nspcc-dev/neofs-api-go/v2/container/grpc"
"google.golang.org/protobuf/encoding/protojson"
)
func (a *Attribute) MarshalJSON() ([]byte, error) {
return protojson.MarshalOptions{
EmitUnpopulated: true,
}.Marshal(
AttributeToGRPCMessage(a),
)
return message.MarshalJSON(a)
}
func (a *Attribute) UnmarshalJSON(data []byte) error {
msg := new(container.Container_Attribute)
if err := protojson.Unmarshal(data, msg); err != nil {
return err
}
*a = *AttributeFromGRPCMessage(msg)
return nil
return message.UnmarshalJSON(a, data, new(container.Container_Attribute))
}
func (c *Container) MarshalJSON() ([]byte, error) {
return protojson.MarshalOptions{
EmitUnpopulated: true,
}.Marshal(
ContainerToGRPCMessage(c),
)
return message.MarshalJSON(c)
}
func (c *Container) UnmarshalJSON(data []byte) error {
msg := new(container.Container)
if err := protojson.Unmarshal(data, msg); err != nil {
return err
}
*c = *ContainerFromGRPCMessage(msg)
return nil
return message.UnmarshalJSON(c, data, new(container.Container))
}