Compare commits
17 commits
master
...
feature/po
Author | SHA1 | Date | |
---|---|---|---|
35e7397d48 | |||
174773454e | |||
b72aa14bab | |||
42e50c9633 | |||
611355510c | |||
ebaf78c8fa | |||
1473fa588f | |||
c27b978770 | |||
8609f29a60 | |||
8ce8cd6ec2 | |||
8580b49c8d | |||
9b90d139c5 | |||
3dfa2f4fd6 | |||
f517e39491 | |||
3639563d80 | |||
610c450a65 | |||
3f92d7bfb0 |
52 changed files with 789 additions and 979 deletions
|
@ -9,13 +9,11 @@ run:
|
|||
# include test files or not, default is true
|
||||
tests: false
|
||||
|
||||
skip-files:
|
||||
- (^|.*/)grpc/(.*)
|
||||
|
||||
# output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
||||
format: tab
|
||||
formats:
|
||||
- format: tab
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
|
@ -67,6 +65,9 @@ linters:
|
|||
fast: false
|
||||
|
||||
issues:
|
||||
exclude-files:
|
||||
- (^|.*/)grpc/(.*)
|
||||
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
exclude-rules:
|
||||
- path: v2 # ignore stutters in universal structures due to protobuf compatibility
|
||||
|
|
34
Makefile
34
Makefile
|
@ -2,6 +2,17 @@
|
|||
SHELL = bash
|
||||
|
||||
VERSION ?= $(shell git describe --tags --match "v*" --abbrev=8 --dirty --always)
|
||||
PROTOC_VERSION ?= 27.2
|
||||
PROTOC_GEN_GO_VERSION ?= $(shell go list -f '{{.Version}}' -m google.golang.org/protobuf)
|
||||
PROTOC_OS_VERSION=osx-x86_64
|
||||
ifeq ($(shell uname), Linux)
|
||||
PROTOC_OS_VERSION=linux-x86_64
|
||||
endif
|
||||
|
||||
BIN = bin
|
||||
PROTOBUF_DIR ?= $(abspath $(BIN))/protobuf
|
||||
PROTOC_DIR ?= $(PROTOBUF_DIR)/protoc-v$(PROTOC_VERSION)
|
||||
PROTOC_GEN_GO_DIR ?= $(PROTOBUF_DIR)/protoc-gen-go-$(PROTOC_GEN_GO_VERSION)
|
||||
|
||||
.PHONY: dep fmts fumpt imports protoc test lint version help
|
||||
|
||||
|
@ -32,16 +43,29 @@ fumpt:
|
|||
@echo "⇒ Processing gofumpt check"
|
||||
@gofumpt -l -w .
|
||||
|
||||
# Install protoc
|
||||
protoc-install:
|
||||
@rm -rf $(PROTOBUF_DIR)
|
||||
@mkdir -p $(PROTOBUF_DIR)
|
||||
@echo "⇒ Installing protoc... "
|
||||
@wget -q -O $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip 'https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_OS_VERSION).zip'
|
||||
@unzip -q -o $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip -d $(PROTOC_DIR)
|
||||
@rm $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip
|
||||
@echo "⇒ Installing protoc-gen-go..."
|
||||
@GOBIN=$(PROTOC_GEN_GO_DIR) go install -v google.golang.org/protobuf/...@$(PROTOC_GEN_GO_VERSION)
|
||||
|
||||
|
||||
# Regenerate code for proto files
|
||||
protoc:
|
||||
@GOPRIVATE=github.com/TrueCloudLab go mod vendor
|
||||
# Install specific version for protobuf lib
|
||||
@go list -f '{{.Path}}/...@{{.Version}}' -m google.golang.org/protobuf | xargs go install -v
|
||||
@if [ ! -d "$(PROTOC_DIR)" ] || [ ! -d "$(PROTOC_GEN_GO_DIR)" ]; then \
|
||||
make protoc-install; \
|
||||
fi
|
||||
# Protoc generate
|
||||
@for f in `find . -type f -name '*.proto' -not -path './vendor/*'`; do \
|
||||
@for f in `find . -type f -name '*.proto'`; do \
|
||||
echo "⇒ Processing $$f "; \
|
||||
protoc \
|
||||
$(PROTOC_DIR)/bin/protoc \
|
||||
--proto_path=.:./vendor:/usr/local/include \
|
||||
--plugin=protoc-gen-go=$(PROTOC_GEN_GO_DIR)/protoc-gen-go \
|
||||
--go_out=. --go_opt=paths=source_relative \
|
||||
--go-grpc_opt=require_unimplemented_servers=false \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \
|
||||
|
|
BIN
accounting/grpc/service.pb.go
generated
BIN
accounting/grpc/service.pb.go
generated
Binary file not shown.
BIN
accounting/grpc/service_grpc.pb.go
generated
BIN
accounting/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
accounting/grpc/types.pb.go
generated
BIN
accounting/grpc/types.pb.go
generated
Binary file not shown.
BIN
acl/grpc/types.pb.go
generated
BIN
acl/grpc/types.pb.go
generated
Binary file not shown.
BIN
ape/grpc/types.pb.go
generated
BIN
ape/grpc/types.pb.go
generated
Binary file not shown.
BIN
apemanager/grpc/service.pb.go
generated
BIN
apemanager/grpc/service.pb.go
generated
Binary file not shown.
BIN
apemanager/grpc/service_grpc.pb.go
generated
BIN
apemanager/grpc/service_grpc.pb.go
generated
Binary file not shown.
|
@ -109,8 +109,7 @@ type RemoveChainResponse struct {
|
|||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type RemoveChainResponseBody struct {
|
||||
}
|
||||
type RemoveChainResponseBody struct{}
|
||||
|
||||
func (r *RemoveChainResponse) SetBody(body *RemoveChainResponseBody) {
|
||||
r.body = body
|
||||
|
|
|
@ -767,151 +767,6 @@ func (r *ListResponse) FromGRPCMessage(m grpc.Message) error {
|
|||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *container.SetExtendedACLRequest_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(container.SetExtendedACLRequest_Body)
|
||||
|
||||
m.SetEacl(r.eacl.ToGRPCMessage().(*aclGRPC.EACLTable))
|
||||
m.SetSignature(toSignatureRFC6979(r.sig))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.SetExtendedACLRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
eacl := v.GetEacl()
|
||||
if eacl == nil {
|
||||
r.eacl = nil
|
||||
} else {
|
||||
if r.eacl == nil {
|
||||
r.eacl = new(acl.Table)
|
||||
}
|
||||
|
||||
err = r.eacl.FromGRPCMessage(eacl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sig := v.GetSignature()
|
||||
if sig == nil {
|
||||
r.sig = nil
|
||||
} else {
|
||||
if r.sig == nil {
|
||||
r.sig = new(refs.Signature)
|
||||
}
|
||||
|
||||
r.sig.SetKey(sig.GetKey())
|
||||
r.sig.SetSign(sig.GetSign())
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *container.SetExtendedACLRequest
|
||||
|
||||
if r != nil {
|
||||
m = new(container.SetExtendedACLRequest)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*container.SetExtendedACLRequest_Body))
|
||||
r.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.SetExtendedACLRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(SetExtendedACLRequestBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *container.SetExtendedACLResponse_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(container.SetExtendedACLResponse_Body)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.SetExtendedACLResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *container.SetExtendedACLResponse
|
||||
|
||||
if r != nil {
|
||||
m = new(container.SetExtendedACLResponse)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*container.SetExtendedACLResponse_Body))
|
||||
r.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.SetExtendedACLResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(SetExtendedACLResponseBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *GetExtendedACLRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *container.GetExtendedACLRequest_Body
|
||||
|
||||
|
@ -1083,198 +938,3 @@ func (r *GetExtendedACLResponse) FromGRPCMessage(m grpc.Message) error {
|
|||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) ToGRPCMessage() grpc.Message {
|
||||
var m *container.AnnounceUsedSpaceRequest_Body_Announcement
|
||||
|
||||
if a != nil {
|
||||
m = new(container.AnnounceUsedSpaceRequest_Body_Announcement)
|
||||
|
||||
m.SetContainerId(a.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
||||
m.SetEpoch(a.epoch)
|
||||
m.SetUsedSpace(a.usedSpace)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.AnnounceUsedSpaceRequest_Body_Announcement)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
cid := v.GetContainerId()
|
||||
if cid == nil {
|
||||
a.cid = nil
|
||||
} else {
|
||||
if a.cid == nil {
|
||||
a.cid = new(refs.ContainerID)
|
||||
}
|
||||
|
||||
err = a.cid.FromGRPCMessage(cid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
a.epoch = v.GetEpoch()
|
||||
a.usedSpace = v.GetUsedSpace()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func UsedSpaceAnnouncementsToGRPCMessage(
|
||||
ids []UsedSpaceAnnouncement,
|
||||
) (res []*container.AnnounceUsedSpaceRequest_Body_Announcement) {
|
||||
if ids != nil {
|
||||
res = make([]*container.AnnounceUsedSpaceRequest_Body_Announcement, 0, len(ids))
|
||||
|
||||
for i := range ids {
|
||||
res = append(res, ids[i].ToGRPCMessage().(*container.AnnounceUsedSpaceRequest_Body_Announcement))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func UsedSpaceAnnouncementssFromGRPCMessage(
|
||||
asV2 []*container.AnnounceUsedSpaceRequest_Body_Announcement,
|
||||
) (res []UsedSpaceAnnouncement, err error) {
|
||||
if asV2 != nil {
|
||||
res = make([]UsedSpaceAnnouncement, len(asV2))
|
||||
|
||||
for i := range asV2 {
|
||||
if asV2[i] != nil {
|
||||
err = res[i].FromGRPCMessage(asV2[i])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *container.AnnounceUsedSpaceRequest_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(container.AnnounceUsedSpaceRequest_Body)
|
||||
|
||||
m.SetAnnouncements(UsedSpaceAnnouncementsToGRPCMessage(r.announcements))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.AnnounceUsedSpaceRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
r.announcements, err = UsedSpaceAnnouncementssFromGRPCMessage(v.GetAnnouncements())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *container.AnnounceUsedSpaceRequest
|
||||
|
||||
if r != nil {
|
||||
m = new(container.AnnounceUsedSpaceRequest)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*container.AnnounceUsedSpaceRequest_Body))
|
||||
r.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.AnnounceUsedSpaceRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(AnnounceUsedSpaceRequestBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *container.AnnounceUsedSpaceResponse_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(container.AnnounceUsedSpaceResponse_Body)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.AnnounceUsedSpaceResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *container.AnnounceUsedSpaceResponse
|
||||
|
||||
if r != nil {
|
||||
m = new(container.AnnounceUsedSpaceResponse)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*container.AnnounceUsedSpaceResponse_Body))
|
||||
r.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*container.AnnounceUsedSpaceResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(AnnounceUsedSpaceResponseBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
|
|
@ -182,46 +182,6 @@ func (m *ListResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
|||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetEacl sets eACL table structure.
|
||||
func (m *SetExtendedACLRequest_Body) SetEacl(v *acl.EACLTable) {
|
||||
m.Eacl = v
|
||||
}
|
||||
|
||||
// SetSignature sets signature of the eACL table structure.
|
||||
func (m *SetExtendedACLRequest_Body) SetSignature(v *refs.SignatureRFC6979) {
|
||||
m.Signature = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the request.
|
||||
func (m *SetExtendedACLRequest) SetBody(v *SetExtendedACLRequest_Body) {
|
||||
m.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the request.
|
||||
func (m *SetExtendedACLRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the request.
|
||||
func (m *SetExtendedACLRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the response.
|
||||
func (m *SetExtendedACLResponse) SetBody(v *SetExtendedACLResponse_Body) {
|
||||
m.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (m *SetExtendedACLResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the response.
|
||||
func (m *SetExtendedACLResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetContainerId sets identifier of the container.
|
||||
func (m *GetExtendedACLRequest_Body) SetContainerId(v *refs.ContainerID) {
|
||||
m.ContainerId = v
|
||||
|
@ -272,53 +232,3 @@ func (m *GetExtendedACLResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
|||
func (m *GetExtendedACLResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetEpoch sets epoch of the size estimation.
|
||||
func (m *AnnounceUsedSpaceRequest_Body_Announcement) SetEpoch(v uint64) {
|
||||
m.Epoch = v
|
||||
}
|
||||
|
||||
// SetContainerId sets identifier of the container.
|
||||
func (m *AnnounceUsedSpaceRequest_Body_Announcement) SetContainerId(v *refs.ContainerID) {
|
||||
m.ContainerId = v
|
||||
}
|
||||
|
||||
// SetUsedSpace sets used space value of the container.
|
||||
func (m *AnnounceUsedSpaceRequest_Body_Announcement) SetUsedSpace(v uint64) {
|
||||
m.UsedSpace = v
|
||||
}
|
||||
|
||||
// SetAnnouncements sets list of announcement for shared containers between nodes.
|
||||
func (m *AnnounceUsedSpaceRequest_Body) SetAnnouncements(v []*AnnounceUsedSpaceRequest_Body_Announcement) {
|
||||
m.Announcements = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the request.
|
||||
func (m *AnnounceUsedSpaceRequest) SetBody(v *AnnounceUsedSpaceRequest_Body) {
|
||||
m.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the request.
|
||||
func (m *AnnounceUsedSpaceRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the request.
|
||||
func (m *AnnounceUsedSpaceRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the response.
|
||||
func (m *AnnounceUsedSpaceResponse) SetBody(v *AnnounceUsedSpaceResponse_Body) {
|
||||
m.Body = v
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (m *AnnounceUsedSpaceResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the response.
|
||||
func (m *AnnounceUsedSpaceResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
|
BIN
container/grpc/service.pb.go
generated
BIN
container/grpc/service.pb.go
generated
Binary file not shown.
BIN
container/grpc/service_grpc.pb.go
generated
BIN
container/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
container/grpc/types.pb.go
generated
BIN
container/grpc/types.pb.go
generated
Binary file not shown.
|
@ -35,20 +35,11 @@ const (
|
|||
|
||||
listRespBodyIDsField = 1
|
||||
|
||||
setEACLReqBodyTableField = 1
|
||||
setEACLReqBodySignatureField = 2
|
||||
|
||||
getEACLReqBodyIDField = 1
|
||||
|
||||
getEACLRespBodyTableField = 1
|
||||
getEACLRespBodySignatureField = 2
|
||||
getEACLRespBodyTokenField = 3
|
||||
|
||||
usedSpaceAnnounceEpochField = 1
|
||||
usedSpaceAnnounceCIDField = 2
|
||||
usedSpaceAnnounceUsedSpaceField = 3
|
||||
|
||||
usedSpaceReqBodyAnnouncementsField = 1
|
||||
)
|
||||
|
||||
func (a *Attribute) StableMarshal(buf []byte) []byte {
|
||||
|
@ -359,50 +350,6 @@ func (r *ListResponseBody) Unmarshal(data []byte) error {
|
|||
return message.Unmarshal(r, data, new(container.ListResponse_Body))
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(setEACLReqBodyTableField, buf[offset:], r.eacl)
|
||||
protoutil.NestedStructureMarshal(setEACLReqBodySignatureField, buf[offset:], r.sig)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) StableSize() (size int) {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.NestedStructureSize(setEACLReqBodyTableField, r.eacl)
|
||||
size += protoutil.NestedStructureSize(setEACLReqBodySignatureField, r.sig)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(container.SetExtendedACLRequest_Body))
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponseBody) StableMarshal(_ []byte) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponseBody) StableSize() (size int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponseBody) Unmarshal([]byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *GetExtendedACLRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
|
@ -464,83 +411,3 @@ func (r *GetExtendedACLResponseBody) StableSize() (size int) {
|
|||
func (r *GetExtendedACLResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(container.GetExtendedACLResponse_Body))
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) StableMarshal(buf []byte) []byte {
|
||||
if a == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, a.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.UInt64Marshal(usedSpaceAnnounceEpochField, buf[offset:], a.epoch)
|
||||
offset += protoutil.NestedStructureMarshal(usedSpaceAnnounceCIDField, buf[offset:], a.cid)
|
||||
protoutil.UInt64Marshal(usedSpaceAnnounceUsedSpaceField, buf[offset:], a.usedSpace)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) StableSize() (size int) {
|
||||
if a == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.UInt64Size(usedSpaceAnnounceEpochField, a.epoch)
|
||||
size += protoutil.NestedStructureSize(usedSpaceAnnounceCIDField, a.cid)
|
||||
size += protoutil.UInt64Size(usedSpaceAnnounceUsedSpaceField, a.usedSpace)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(a, data, new(container.AnnounceUsedSpaceRequest_Body_Announcement))
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
for i := range r.announcements {
|
||||
offset += protoutil.NestedStructureMarshal(usedSpaceReqBodyAnnouncementsField, buf[offset:], &r.announcements[i])
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) StableSize() (size int) {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
for i := range r.announcements {
|
||||
size += protoutil.NestedStructureSize(usedSpaceReqBodyAnnouncementsField, &r.announcements[i])
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(container.AnnounceUsedSpaceRequest_Body))
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponseBody) StableMarshal(_ []byte) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponseBody) StableSize() (size int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponseBody) Unmarshal([]byte) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ func TestMessageConvert(t *testing.T) {
|
|||
func(empty bool) message.Message { return containertest.GenerateListRequest(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateListResponseBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateListResponse(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateSetExtendedACLRequestBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateSetExtendedACLRequest(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateGetRequestBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateGetRequest(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateGetResponseBody(empty) },
|
||||
|
@ -38,10 +36,5 @@ func TestMessageConvert(t *testing.T) {
|
|||
func(empty bool) message.Message { return containertest.GenerateGetExtendedACLRequest(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateGetExtendedACLResponseBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateGetExtendedACLResponse(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateUsedSpaceAnnouncement(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateAnnounceUsedSpaceRequestBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateAnnounceUsedSpaceRequest(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateAnnounceUsedSpaceResponseBody(empty) },
|
||||
func(empty bool) message.Message { return containertest.GenerateAnnounceUsedSpaceResponse(empty) },
|
||||
)
|
||||
}
|
||||
|
|
|
@ -235,50 +235,6 @@ func GenerateListResponse(empty bool) *container.ListResponse {
|
|||
return m
|
||||
}
|
||||
|
||||
func GenerateSetExtendedACLRequestBody(empty bool) *container.SetExtendedACLRequestBody {
|
||||
m := new(container.SetExtendedACLRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetEACL(acltest.GenerateTable(false))
|
||||
}
|
||||
|
||||
m.SetSignature(refstest.GenerateSignature(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateSetExtendedACLRequest(empty bool) *container.SetExtendedACLRequest {
|
||||
m := new(container.SetExtendedACLRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateSetExtendedACLRequestBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateSetExtendedACLResponseBody(_ bool) *container.SetExtendedACLResponseBody {
|
||||
m := new(container.SetExtendedACLResponseBody)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateSetExtendedACLResponse(empty bool) *container.SetExtendedACLResponse {
|
||||
m := new(container.SetExtendedACLResponse)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateSetExtendedACLResponseBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateGetExtendedACLRequestBody(empty bool) *container.GetExtendedACLRequestBody {
|
||||
m := new(container.GetExtendedACLRequestBody)
|
||||
|
||||
|
@ -327,70 +283,3 @@ func GenerateGetExtendedACLResponse(empty bool) *container.GetExtendedACLRespons
|
|||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateUsedSpaceAnnouncement(empty bool) *container.UsedSpaceAnnouncement {
|
||||
m := new(container.UsedSpaceAnnouncement)
|
||||
|
||||
if !empty {
|
||||
m.SetContainerID(refstest.GenerateContainerID(false))
|
||||
m.SetEpoch(1)
|
||||
m.SetUsedSpace(2)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateUsedSpaceAnnouncements(empty bool) []container.UsedSpaceAnnouncement {
|
||||
var res []container.UsedSpaceAnnouncement
|
||||
|
||||
if !empty {
|
||||
res = append(res,
|
||||
*GenerateUsedSpaceAnnouncement(false),
|
||||
*GenerateUsedSpaceAnnouncement(false),
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func GenerateAnnounceUsedSpaceRequestBody(empty bool) *container.AnnounceUsedSpaceRequestBody {
|
||||
m := new(container.AnnounceUsedSpaceRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetAnnouncements(GenerateUsedSpaceAnnouncements(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceUsedSpaceRequest(empty bool) *container.AnnounceUsedSpaceRequest {
|
||||
m := new(container.AnnounceUsedSpaceRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceUsedSpaceRequestBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceUsedSpaceResponseBody(_ bool) *container.AnnounceUsedSpaceResponseBody {
|
||||
m := new(container.AnnounceUsedSpaceResponseBody)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAnnounceUsedSpaceResponse(empty bool) *container.AnnounceUsedSpaceResponse {
|
||||
m := new(container.AnnounceUsedSpaceResponse)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateAnnounceUsedSpaceResponseBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -110,26 +110,6 @@ type ListResponse struct {
|
|||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type SetExtendedACLRequestBody struct {
|
||||
eacl *acl.Table
|
||||
|
||||
sig *refs.Signature
|
||||
}
|
||||
|
||||
type SetExtendedACLRequest struct {
|
||||
body *SetExtendedACLRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type SetExtendedACLResponseBody struct{}
|
||||
|
||||
type SetExtendedACLResponse struct {
|
||||
body *SetExtendedACLResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type GetExtendedACLRequestBody struct {
|
||||
cid *refs.ContainerID
|
||||
}
|
||||
|
@ -154,32 +134,6 @@ type GetExtendedACLResponse struct {
|
|||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type UsedSpaceAnnouncement struct {
|
||||
epoch uint64
|
||||
|
||||
cid *refs.ContainerID
|
||||
|
||||
usedSpace uint64
|
||||
}
|
||||
|
||||
type AnnounceUsedSpaceRequestBody struct {
|
||||
announcements []UsedSpaceAnnouncement
|
||||
}
|
||||
|
||||
type AnnounceUsedSpaceRequest struct {
|
||||
body *AnnounceUsedSpaceRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type AnnounceUsedSpaceResponseBody struct{}
|
||||
|
||||
type AnnounceUsedSpaceResponse struct {
|
||||
body *AnnounceUsedSpaceResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
func (a *Attribute) GetKey() string {
|
||||
if a != nil {
|
||||
return a.key
|
||||
|
@ -516,56 +470,6 @@ func (r *ListResponse) SetBody(v *ListResponseBody) {
|
|||
r.body = v
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) GetEACL() *acl.Table {
|
||||
if r != nil {
|
||||
return r.eacl
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) SetEACL(v *acl.Table) {
|
||||
r.eacl = v
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) GetSignature() *refs.Signature {
|
||||
if r != nil {
|
||||
return r.sig
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequestBody) SetSignature(v *refs.Signature) {
|
||||
// TODO: (neofs-api-go#381) avoid this hack (e.g. create refs.SignatureRFC6979 type)
|
||||
v.SetScheme(0)
|
||||
r.sig = v
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequest) GetBody() *SetExtendedACLRequestBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLRequest) SetBody(v *SetExtendedACLRequestBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponse) GetBody() *SetExtendedACLResponseBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SetExtendedACLResponse) SetBody(v *SetExtendedACLResponseBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
||||
func (r *GetExtendedACLRequestBody) GetContainerID() *refs.ContainerID {
|
||||
if r != nil {
|
||||
return r.cid
|
||||
|
@ -643,75 +547,3 @@ func (r *GetExtendedACLResponse) GetBody() *GetExtendedACLResponseBody {
|
|||
func (r *GetExtendedACLResponse) SetBody(v *GetExtendedACLResponseBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) GetEpoch() uint64 {
|
||||
if a != nil {
|
||||
return a.epoch
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) SetEpoch(v uint64) {
|
||||
a.epoch = v
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) GetUsedSpace() uint64 {
|
||||
if a != nil {
|
||||
return a.usedSpace
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) SetUsedSpace(v uint64) {
|
||||
a.usedSpace = v
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) GetContainerID() *refs.ContainerID {
|
||||
if a != nil {
|
||||
return a.cid
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *UsedSpaceAnnouncement) SetContainerID(v *refs.ContainerID) {
|
||||
a.cid = v
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) GetAnnouncements() []UsedSpaceAnnouncement {
|
||||
if r != nil {
|
||||
return r.announcements
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequestBody) SetAnnouncements(v []UsedSpaceAnnouncement) {
|
||||
r.announcements = v
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequest) GetBody() *AnnounceUsedSpaceRequestBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceRequest) SetBody(v *AnnounceUsedSpaceRequestBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponse) GetBody() *AnnounceUsedSpaceResponseBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AnnounceUsedSpaceResponse) SetBody(v *AnnounceUsedSpaceResponseBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
|
13
go.mod
13
go.mod
|
@ -5,22 +5,21 @@ go 1.20
|
|||
require (
|
||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
||||
github.com/stretchr/testify v1.8.3
|
||||
golang.org/x/sync v0.2.0
|
||||
google.golang.org/grpc v1.55.0
|
||||
golang.org/x/sync v0.6.0
|
||||
google.golang.org/grpc v1.63.2
|
||||
google.golang.org/protobuf v1.33.0
|
||||
)
|
||||
|
||||
require (
|
||||
git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
33
go.sum
33
go.sum
|
@ -5,11 +5,7 @@ git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0/go.mod h1:okpbKfVYf/BpejtfFTfhZqFP+
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
|
@ -23,21 +19,18 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
|
||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
|
||||
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
|
||||
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
|
||||
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
|
||||
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
|
BIN
lock/grpc/types.pb.go
generated
BIN
lock/grpc/types.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/service.pb.go
generated
BIN
netmap/grpc/service.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/service_grpc.pb.go
generated
BIN
netmap/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
netmap/grpc/types.pb.go
generated
BIN
netmap/grpc/types.pb.go
generated
Binary file not shown.
|
@ -111,6 +111,7 @@ const (
|
|||
OR
|
||||
AND
|
||||
NOT
|
||||
LIKE
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -2345,3 +2345,217 @@ func (r *PutSingleResponse) FromGRPCMessage(m grpc.Message) error {
|
|||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest_Body_Patch
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest_Body_Patch)
|
||||
|
||||
m.SetSourceRange(r.Range.ToGRPCMessage().(*object.Range))
|
||||
m.SetChunk(r.Chunk)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest_Body_Patch)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
srcRange := v.GetSourceRange()
|
||||
if srcRange == nil {
|
||||
r.Range = nil
|
||||
} else {
|
||||
if r.Range == nil {
|
||||
r.Range = new(Range)
|
||||
}
|
||||
|
||||
err = r.Range.FromGRPCMessage(srcRange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
r.Chunk = v.GetChunk()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest_Body)
|
||||
|
||||
m.SetAddress(r.address.ToGRPCMessage().(*refsGRPC.Address))
|
||||
m.SetNewAttributes(AttributesToGRPC(r.newAttributes))
|
||||
m.SetReplaceAttributes(r.replaceAttributes)
|
||||
m.SetPatch(r.patch.ToGRPCMessage().(*object.PatchRequest_Body_Patch))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
addr := v.GetAddress()
|
||||
if addr == nil {
|
||||
r.address = nil
|
||||
} else {
|
||||
if r.address == nil {
|
||||
r.address = new(refs.Address)
|
||||
}
|
||||
|
||||
err = r.address.FromGRPCMessage(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
r.newAttributes, err = AttributesFromGRPC(v.GetNewAttributes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.replaceAttributes = v.GetReplaceAttributes()
|
||||
|
||||
patch := v.GetPatch()
|
||||
if patch == nil {
|
||||
r.patch = nil
|
||||
} else {
|
||||
if r.patch == nil {
|
||||
r.patch = new(PatchRequestBodyPatch)
|
||||
}
|
||||
|
||||
err = r.patch.FromGRPCMessage(patch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*object.PatchRequest_Body))
|
||||
r.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(PatchRequestBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchResponse_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchResponse_Body)
|
||||
|
||||
m.SetObjectID(r.ObjectID.ToGRPCMessage().(*refsGRPC.ObjectID))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
objID := v.GetObjectId()
|
||||
if objID == nil {
|
||||
r.ObjectID = nil
|
||||
} else {
|
||||
if r.ObjectID == nil {
|
||||
r.ObjectID = new(refs.ObjectID)
|
||||
}
|
||||
|
||||
err = r.ObjectID.FromGRPCMessage(objID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchResponse
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchResponse)
|
||||
|
||||
m.SetBody(r.Body.ToGRPCMessage().(*object.PatchResponse_Body))
|
||||
r.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.Body = nil
|
||||
} else {
|
||||
if r.Body == nil {
|
||||
r.Body = new(PatchResponseBody)
|
||||
}
|
||||
|
||||
err = r.Body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
|
|
@ -556,3 +556,55 @@ func (m *PutSingleResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
|||
func (m *PutSingleResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetAddress(addr *refs.Address) {
|
||||
m.Address = addr
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetNewAttributes(attrs []*Header_Attribute) {
|
||||
m.NewAttributes = attrs
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetReplaceAttributes(replaceAttributes bool) {
|
||||
m.ReplaceAttributes = replaceAttributes
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetPatch(patch *PatchRequest_Body_Patch) {
|
||||
m.Patch = patch
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body_Patch) SetSourceRange(r *Range) {
|
||||
m.SourceRange = r
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body_Patch) SetChunk(chunk []byte) {
|
||||
m.Chunk = chunk
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetBody(b *PatchRequest_Body) {
|
||||
m.Body = b
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchResponse_Body) SetObjectID(objectID *refs.ObjectID) {
|
||||
m.ObjectId = objectID
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetBody(b *PatchResponse_Body) {
|
||||
m.Body = b
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
|
BIN
object/grpc/service.pb.go
generated
BIN
object/grpc/service.pb.go
generated
Binary file not shown.
BIN
object/grpc/service_grpc.pb.go
generated
BIN
object/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
object/grpc/types.pb.go
generated
BIN
object/grpc/types.pb.go
generated
Binary file not shown.
|
@ -132,6 +132,16 @@ const (
|
|||
|
||||
putSingleReqObjectField = 1
|
||||
putSingleReqCopiesNumberField = 2
|
||||
|
||||
patchRequestBodyPatchRangeField = 1
|
||||
patchRequestBodyPatchChunkField = 2
|
||||
|
||||
patchRequestBodyAddrField = 1
|
||||
patchRequestBodyNewAttrsField = 2
|
||||
patchRequestBodyReplaceAttrField = 3
|
||||
patchRequestBodyPatchField = 4
|
||||
|
||||
patchResponseBodyObjectIDField = 1
|
||||
)
|
||||
|
||||
func (h *ShortHeader) StableMarshal(buf []byte) []byte {
|
||||
|
@ -1314,3 +1324,105 @@ func (r *PutSingleResponseBody) StableSize() int {
|
|||
func (r *PutSingleResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PutSingleResponse_Body))
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.Range)
|
||||
proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchRequestBodyPatchRangeField, r.Range)
|
||||
size += proto.BytesSize(patchRequestBodyPatchChunkField, r.Chunk)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchRequest_Body_Patch))
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyAddrField, buf[offset:], r.address)
|
||||
for i := range r.newAttributes {
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyNewAttrsField, buf[offset:], &r.newAttributes[i])
|
||||
}
|
||||
offset += proto.BoolMarshal(patchRequestBodyReplaceAttrField, buf[offset:], r.replaceAttributes)
|
||||
proto.NestedStructureMarshal(patchRequestBodyPatchField, buf[offset:], r.patch)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchRequestBodyAddrField, r.address)
|
||||
for i := range r.newAttributes {
|
||||
size += proto.NestedStructureSize(patchRequestBodyNewAttrsField, &r.newAttributes[i])
|
||||
}
|
||||
size += proto.BoolSize(patchRequestBodyReplaceAttrField, r.replaceAttributes)
|
||||
size += proto.NestedStructureSize(patchRequestBodyPatchField, r.patch)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchRequest_Body))
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchResponseBodyObjectIDField, r.ObjectID)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
proto.NestedStructureMarshal(patchResponseBodyObjectIDField, buf[offset:], r.ObjectID)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchResponse_Body))
|
||||
}
|
||||
|
|
|
@ -56,5 +56,10 @@ func TestMessageConvert(t *testing.T) {
|
|||
func(empty bool) message.Message { return objecttest.GenerateLock(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePutSingleRequest(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePutSingleResponse(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequestBodyPatch(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequestBody(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequest(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchResponseBody(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchResponse(empty) },
|
||||
)
|
||||
}
|
||||
|
|
|
@ -691,6 +691,63 @@ func GeneratePutSingleResponse(empty bool) *object.PutSingleResponse {
|
|||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequestBodyPatch(empty bool) *object.PatchRequestBodyPatch {
|
||||
m := new(object.PatchRequestBodyPatch)
|
||||
|
||||
if !empty {
|
||||
m.Range = GenerateRange(false)
|
||||
m.Chunk = []byte("GeneratePatchRequestBodyPatch")
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequestBody(empty bool) *object.PatchRequestBody {
|
||||
m := new(object.PatchRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetAddress(refstest.GenerateAddress(empty))
|
||||
m.SetNewAttributes(GenerateAttributes(empty))
|
||||
m.SetReplaceAttributes(false)
|
||||
m.SetPatch(GeneratePatchRequestBodyPatch(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequest(empty bool) *object.PatchRequest {
|
||||
m := new(object.PatchRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GeneratePatchRequestBody(empty))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchResponseBody(empty bool) *object.PatchResponseBody {
|
||||
m := new(object.PatchResponseBody)
|
||||
|
||||
if !empty {
|
||||
m.ObjectID = refstest.GenerateObjectID(empty)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchResponse(empty bool) *object.PatchResponse {
|
||||
m := new(object.PatchResponse)
|
||||
|
||||
if !empty {
|
||||
m.Body = GeneratePatchResponseBody(empty)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func randomInt(n int) int {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(n)
|
||||
}
|
||||
|
|
104
object/types.go
104
object/types.go
|
@ -349,6 +349,38 @@ type PutSingleResponse struct {
|
|||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type PatchRequestBodyPatch struct {
|
||||
Range *Range
|
||||
|
||||
Chunk []byte
|
||||
}
|
||||
|
||||
type PatchRequestBody struct {
|
||||
address *refs.Address
|
||||
|
||||
newAttributes []Attribute
|
||||
|
||||
replaceAttributes bool
|
||||
|
||||
patch *PatchRequestBodyPatch
|
||||
}
|
||||
|
||||
type PatchRequest struct {
|
||||
body *PatchRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type PatchResponseBody struct {
|
||||
ObjectID *refs.ObjectID
|
||||
}
|
||||
|
||||
type PatchResponse struct {
|
||||
Body *PatchResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
const (
|
||||
TypeRegular Type = iota
|
||||
TypeTombstone
|
||||
|
@ -1511,6 +1543,78 @@ func (r *PutSingleResponse) SetBody(v *PutSingleResponseBody) {
|
|||
r.body = v
|
||||
}
|
||||
|
||||
func (r *PatchRequest) GetBody() *PatchRequestBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequest) SetBody(v *PatchRequestBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) GetAddress() *refs.Address {
|
||||
if r != nil {
|
||||
return r.address
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) SetAddress(addr *refs.Address) {
|
||||
r.address = addr
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) GetNewAttributes() []Attribute {
|
||||
if r != nil {
|
||||
return r.newAttributes
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) SetNewAttributes(attrs []Attribute) {
|
||||
r.newAttributes = attrs
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) GetReplaceAttributes() bool {
|
||||
if r != nil {
|
||||
return r.replaceAttributes
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) SetReplaceAttributes(replace bool) {
|
||||
r.replaceAttributes = replace
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) GetPatch() *PatchRequestBodyPatch {
|
||||
if r != nil {
|
||||
return r.patch
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) SetPatch(patch *PatchRequestBodyPatch) {
|
||||
r.patch = patch
|
||||
}
|
||||
|
||||
func (r *PatchResponse) GetBody() *PatchResponseBody {
|
||||
if r != nil {
|
||||
return r.Body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchResponse) SetBody(v *PatchResponseBody) {
|
||||
r.Body = v
|
||||
}
|
||||
|
||||
func (s *ECInfo) getObjectPart() {}
|
||||
|
||||
func (s *ECInfo) getHeaderPart() {}
|
||||
|
|
BIN
refs/grpc/types.pb.go
generated
BIN
refs/grpc/types.pb.go
generated
Binary file not shown.
|
@ -2,8 +2,16 @@ package client
|
|||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Conn is an interface for grpc client connection.
|
||||
type Conn interface {
|
||||
grpc.ClientConnInterface
|
||||
io.Closer
|
||||
}
|
||||
|
||||
// Conn returns underlying connection.
|
||||
//
|
||||
// Returns non-nil result after the first Init() call
|
||||
|
|
|
@ -25,7 +25,7 @@ type cfg struct {
|
|||
tlsCfg *tls.Config
|
||||
grpcDialOpts []grpc.DialOption
|
||||
|
||||
conn *grpc.ClientConn
|
||||
conn Conn
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -114,7 +114,7 @@ func WithTLSCfg(v *tls.Config) Option {
|
|||
|
||||
// WithGRPCConn returns option to specify
|
||||
// gRPC virtual connection.
|
||||
func WithGRPCConn(v *grpc.ClientConn) Option {
|
||||
func WithGRPCConn(v Conn) Option {
|
||||
return func(c *cfg) {
|
||||
if v != nil {
|
||||
c.conn = v
|
||||
|
|
|
@ -13,7 +13,6 @@ const (
|
|||
rpcContainerGet = "Get"
|
||||
rpcContainerDel = "Delete"
|
||||
rpcContainerList = "List"
|
||||
rpcContainerSetEACL = "SetExtendedACL"
|
||||
rpcContainerGetEACL = "GetExtendedACL"
|
||||
rpcContainerUsedSpace = "AnnounceUsedSpace"
|
||||
)
|
||||
|
@ -82,22 +81,6 @@ func ListContainers(
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
// SetEACL executes ContainerService.SetExtendedACL RPC.
|
||||
func SetEACL(
|
||||
cli *client.Client,
|
||||
req *container.SetExtendedACLRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*container.PutResponse, error) {
|
||||
resp := new(container.PutResponse)
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceContainer, rpcContainerSetEACL), req, resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// GetEACL executes ContainerService.GetExtendedACL RPC.
|
||||
func GetEACL(
|
||||
cli *client.Client,
|
||||
|
@ -113,19 +96,3 @@ func GetEACL(
|
|||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// AnnounceUsedSpace executes ContainerService.AnnounceUsedSpace RPC.
|
||||
func AnnounceUsedSpace(
|
||||
cli *client.Client,
|
||||
req *container.AnnounceUsedSpaceRequest,
|
||||
opts ...client.CallOption,
|
||||
) (*container.PutResponse, error) {
|
||||
resp := new(container.PutResponse)
|
||||
|
||||
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceContainer, rpcContainerUsedSpace), req, resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ const (
|
|||
rpcObjectHead = "Head"
|
||||
rpcObjectDelete = "Delete"
|
||||
rpcObjectPutSingle = "PutSingle"
|
||||
rpcObjectPatch = "Patch"
|
||||
)
|
||||
|
||||
// PutRequestWriter is an object.PutRequest
|
||||
|
@ -205,3 +206,38 @@ func PutSingleObject(
|
|||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// PatchRequestWriter is an object.PatchRequest
|
||||
// message streaming component.
|
||||
type PatchRequestWriter struct {
|
||||
wc client.MessageWriterCloser
|
||||
|
||||
resp message.Message
|
||||
}
|
||||
|
||||
// Write writes req to the stream.
|
||||
func (w *PatchRequestWriter) Write(req *object.PatchRequest) error {
|
||||
return w.wc.WriteMessage(req)
|
||||
}
|
||||
|
||||
// Close closes the stream.
|
||||
func (w *PatchRequestWriter) Close() error {
|
||||
return w.wc.Close()
|
||||
}
|
||||
|
||||
// Patch executes ObjectService.Patch RPC.
|
||||
func Patch(
|
||||
cli *client.Client,
|
||||
resp *object.PatchResponse,
|
||||
opts ...client.CallOption,
|
||||
) (*PatchRequestWriter, error) {
|
||||
wc, err := client.OpenClientStream(cli, common.CallMethodInfoClientStream(serviceObject, rpcObjectPatch), resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PatchRequestWriter{
|
||||
wc: wc,
|
||||
resp: resp,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -641,6 +641,8 @@ func ObjectSessionVerbToGRPCField(v ObjectSessionVerb) session.ObjectSessionCont
|
|||
return session.ObjectSessionContext_RANGE
|
||||
case ObjectVerbRangeHash:
|
||||
return session.ObjectSessionContext_RANGEHASH
|
||||
case ObjectVerbPatch:
|
||||
return session.ObjectSessionContext_PATCH
|
||||
default:
|
||||
return session.ObjectSessionContext_VERB_UNSPECIFIED
|
||||
}
|
||||
|
@ -662,6 +664,8 @@ func ObjectSessionVerbFromGRPCField(v session.ObjectSessionContext_Verb) ObjectS
|
|||
return ObjectVerbRange
|
||||
case session.ObjectSessionContext_RANGEHASH:
|
||||
return ObjectVerbRangeHash
|
||||
case session.ObjectSessionContext_PATCH:
|
||||
return ObjectVerbPatch
|
||||
default:
|
||||
return ObjectVerbUnknown
|
||||
}
|
||||
|
|
BIN
session/grpc/service.pb.go
generated
BIN
session/grpc/service.pb.go
generated
Binary file not shown.
BIN
session/grpc/service_grpc.pb.go
generated
BIN
session/grpc/service_grpc.pb.go
generated
Binary file not shown.
BIN
session/grpc/types.pb.go
generated
BIN
session/grpc/types.pb.go
generated
Binary file not shown.
|
@ -175,6 +175,7 @@ const (
|
|||
ObjectVerbDelete
|
||||
ObjectVerbRange
|
||||
ObjectVerbRangeHash
|
||||
ObjectVerbPatch
|
||||
)
|
||||
|
||||
func (c *CreateRequestBody) GetOwnerID() *refs.OwnerID {
|
||||
|
|
|
@ -46,18 +46,10 @@ func serviceMessageBody(req any) stableMarshaler {
|
|||
return v.GetBody()
|
||||
case *container.ListResponse:
|
||||
return v.GetBody()
|
||||
case *container.SetExtendedACLRequest:
|
||||
return v.GetBody()
|
||||
case *container.SetExtendedACLResponse:
|
||||
return v.GetBody()
|
||||
case *container.GetExtendedACLRequest:
|
||||
return v.GetBody()
|
||||
case *container.GetExtendedACLResponse:
|
||||
return v.GetBody()
|
||||
case *container.AnnounceUsedSpaceRequest:
|
||||
return v.GetBody()
|
||||
case *container.AnnounceUsedSpaceResponse:
|
||||
return v.GetBody()
|
||||
|
||||
/* Object */
|
||||
case *object.PutRequest:
|
||||
|
@ -92,6 +84,10 @@ func serviceMessageBody(req any) stableMarshaler {
|
|||
return v.GetBody()
|
||||
case *object.PutSingleResponse:
|
||||
return v.GetBody()
|
||||
case *object.PatchRequest:
|
||||
return v.GetBody()
|
||||
case *object.PatchResponse:
|
||||
return v.GetBody()
|
||||
|
||||
/* Netmap */
|
||||
case *netmap.LocalNodeInfoRequest:
|
||||
|
|
BIN
status/grpc/types.pb.go
generated
BIN
status/grpc/types.pb.go
generated
Binary file not shown.
BIN
tombstone/grpc/types.pb.go
generated
BIN
tombstone/grpc/types.pb.go
generated
Binary file not shown.
|
@ -1,12 +1,14 @@
|
|||
package proto_test
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
goproto "google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
|
@ -33,6 +35,8 @@ type stableRepPrimitives struct {
|
|||
FieldD []uint32
|
||||
FieldE []int64
|
||||
FieldF []uint64
|
||||
|
||||
FieldFu []uint64
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -185,6 +189,20 @@ func (s *stableRepPrimitives) stableMarshal(buf []byte, wrongField bool) ([]byte
|
|||
}
|
||||
i += proto.RepeatedUInt64Marshal(fieldNum, buf, s.FieldF)
|
||||
|
||||
fieldNum = 7
|
||||
if wrongField {
|
||||
fieldNum++
|
||||
}
|
||||
for j := range s.FieldFu {
|
||||
{
|
||||
prefix := protowire.EncodeTag(
|
||||
protowire.Number(fieldNum),
|
||||
protowire.VarintType)
|
||||
i += binary.PutUvarint(buf[i:], uint64(prefix))
|
||||
i += binary.PutUvarint(buf[i:], s.FieldFu[j])
|
||||
}
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
|
@ -196,7 +214,12 @@ func (s *stableRepPrimitives) stableSize() int {
|
|||
f5, _ := proto.RepeatedInt64Size(5, s.FieldE)
|
||||
f6, _ := proto.RepeatedUInt64Size(6, s.FieldF)
|
||||
|
||||
return f1 + f2 + f3 + f4 + f5 + f6
|
||||
var f7 int
|
||||
for i := range s.FieldFu {
|
||||
f7 += protowire.SizeGroup(protowire.Number(7), protowire.SizeVarint(s.FieldFu[i]))
|
||||
}
|
||||
|
||||
return f1 + f2 + f3 + f4 + f5 + f6 + f7
|
||||
}
|
||||
|
||||
func TestBytesMarshal(t *testing.T) {
|
||||
|
@ -404,6 +427,22 @@ func TestRepeatedUInt64Marshal(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestRepeatedUInt64MarshalUnpacked(t *testing.T) {
|
||||
t.Run("not empty", func(t *testing.T) {
|
||||
data := []uint64{0, 1, 2, 3, 4, 5}
|
||||
testRepeatedUInt64MarshalUnpacked(t, data, false)
|
||||
testRepeatedUInt64MarshalUnpacked(t, data, true)
|
||||
})
|
||||
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
testRepeatedUInt64MarshalUnpacked(t, []uint64{}, false)
|
||||
})
|
||||
|
||||
t.Run("nil", func(t *testing.T) {
|
||||
testRepeatedUInt64MarshalUnpacked(t, nil, false)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFixed64Marshal(t *testing.T) {
|
||||
t.Run("zero", func(t *testing.T) {
|
||||
testFixed64Marshal(t, 0, false)
|
||||
|
@ -439,7 +478,7 @@ func TestFixed32Marshal(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongField bool) *test.Primitives {
|
||||
func testMarshal(t *testing.T, c stablePrimitives, tr *test.Primitives, wrongField bool) *test.Primitives {
|
||||
var (
|
||||
wire []byte
|
||||
err error
|
||||
|
@ -447,7 +486,7 @@ func testMarshal(t *testing.T, c stablePrimitives, tr test.Primitives, wrongFiel
|
|||
wire, err = c.stableMarshal(nil, wrongField)
|
||||
require.NoError(t, err)
|
||||
|
||||
wireGen, err := goproto.Marshal(&tr)
|
||||
wireGen, err := goproto.Marshal(tr)
|
||||
require.NoError(t, err)
|
||||
|
||||
if !wrongField {
|
||||
|
@ -470,7 +509,7 @@ func testBytesMarshal(t *testing.T, data []byte, wrongField bool) {
|
|||
transport = test.Primitives{FieldA: data}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldA, len(data))
|
||||
|
@ -488,7 +527,7 @@ func testStringMarshal(t *testing.T, s string, wrongField bool) {
|
|||
transport = test.Primitives{FieldB: s}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldB, len(s))
|
||||
|
@ -506,7 +545,7 @@ func testBoolMarshal(t *testing.T, b bool, wrongField bool) {
|
|||
transport = test.Primitives{FieldC: b}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, b, result.FieldC)
|
||||
|
@ -521,7 +560,7 @@ func testInt32Marshal(t *testing.T, n int32, wrongField bool) {
|
|||
transport = test.Primitives{FieldD: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldD)
|
||||
|
@ -536,7 +575,7 @@ func testUInt32Marshal(t *testing.T, n uint32, wrongField bool) {
|
|||
transport = test.Primitives{FieldE: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldE)
|
||||
|
@ -551,7 +590,7 @@ func testInt64Marshal(t *testing.T, n int64, wrongField bool) {
|
|||
transport = test.Primitives{FieldF: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldF)
|
||||
|
@ -566,7 +605,7 @@ func testUInt64Marshal(t *testing.T, n uint64, wrongField bool) {
|
|||
transport = test.Primitives{FieldG: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldG)
|
||||
|
@ -581,7 +620,7 @@ func testFloat64Marshal(t *testing.T, n float64, wrongField bool) {
|
|||
transport = test.Primitives{FieldJ: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldJ)
|
||||
|
@ -596,7 +635,7 @@ func testEnumMarshal(t *testing.T, e SomeEnum, wrongField bool) {
|
|||
transport = test.Primitives{FieldH: test.Primitives_SomeEnum(e)}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.EqualValues(t, custom.FieldH, result.FieldH)
|
||||
|
@ -605,7 +644,7 @@ func testEnumMarshal(t *testing.T, e SomeEnum, wrongField bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives, wrongField bool) *test.RepPrimitives {
|
||||
func testRepMarshal(t *testing.T, c stableRepPrimitives, tr *test.RepPrimitives, wrongField bool) *test.RepPrimitives {
|
||||
var (
|
||||
wire []byte
|
||||
err error
|
||||
|
@ -613,7 +652,7 @@ func testRepMarshal(t *testing.T, c stableRepPrimitives, tr test.RepPrimitives,
|
|||
wire, err = c.stableMarshal(nil, wrongField)
|
||||
require.NoError(t, err)
|
||||
|
||||
wireGen, err := goproto.Marshal(&tr)
|
||||
wireGen, err := goproto.Marshal(tr)
|
||||
require.NoError(t, err)
|
||||
|
||||
if !wrongField {
|
||||
|
@ -636,7 +675,7 @@ func testRepeatedBytesMarshal(t *testing.T, data [][]byte, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldA: data}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldA, len(data))
|
||||
|
@ -654,7 +693,7 @@ func testRepeatedStringMarshal(t *testing.T, s []string, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldB: s}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldB, len(s))
|
||||
|
@ -672,7 +711,7 @@ func testRepeatedInt32Marshal(t *testing.T, n []int32, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldC: n}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldC, len(n))
|
||||
|
@ -690,7 +729,7 @@ func testRepeatedUInt32Marshal(t *testing.T, n []uint32, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldD: n}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldD, len(n))
|
||||
|
@ -708,7 +747,7 @@ func testRepeatedInt64Marshal(t *testing.T, n []int64, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldE: n}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldE, len(n))
|
||||
|
@ -726,7 +765,7 @@ func testRepeatedUInt64Marshal(t *testing.T, n []uint64, wrongField bool) {
|
|||
transport = test.RepPrimitives{FieldF: n}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, transport, wrongField)
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldF, len(n))
|
||||
|
@ -738,13 +777,31 @@ func testRepeatedUInt64Marshal(t *testing.T, n []uint64, wrongField bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func testRepeatedUInt64MarshalUnpacked(t *testing.T, n []uint64, wrongField bool) {
|
||||
var (
|
||||
custom = stableRepPrimitives{FieldFu: n}
|
||||
transport = test.RepPrimitives{FieldFu: n}
|
||||
)
|
||||
|
||||
result := testRepMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Len(t, result.FieldFu, len(n))
|
||||
if len(n) > 0 {
|
||||
require.Equal(t, n, result.FieldFu)
|
||||
}
|
||||
} else {
|
||||
require.Len(t, result.FieldFu, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func testFixed64Marshal(t *testing.T, n uint64, wrongField bool) {
|
||||
var (
|
||||
custom = stablePrimitives{FieldI: n}
|
||||
transport = test.Primitives{FieldI: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldI)
|
||||
|
@ -759,7 +816,7 @@ func testFixed32Marshal(t *testing.T, n uint32, wrongField bool) {
|
|||
transport = test.Primitives{FieldK: n}
|
||||
)
|
||||
|
||||
result := testMarshal(t, custom, transport, wrongField)
|
||||
result := testMarshal(t, custom, &transport, wrongField)
|
||||
|
||||
if !wrongField {
|
||||
require.Equal(t, n, result.FieldK)
|
||||
|
|
BIN
util/proto/test/test.pb.go
generated
BIN
util/proto/test/test.pb.go
generated
Binary file not shown.
|
@ -5,30 +5,31 @@ package test;
|
|||
option go_package = "util/proto/test";
|
||||
|
||||
message Primitives {
|
||||
bytes field_a = 1;
|
||||
string field_b = 2;
|
||||
bool field_c = 200;
|
||||
int32 field_d = 201;
|
||||
uint32 field_e = 202;
|
||||
int64 field_f = 203;
|
||||
uint64 field_g = 204;
|
||||
fixed64 field_i = 205;
|
||||
double field_j = 206;
|
||||
fixed32 field_k = 207;
|
||||
bytes field_a = 1;
|
||||
string field_b = 2;
|
||||
bool field_c = 200;
|
||||
int32 field_d = 201;
|
||||
uint32 field_e = 202;
|
||||
int64 field_f = 203;
|
||||
uint64 field_g = 204;
|
||||
fixed64 field_i = 205;
|
||||
double field_j = 206;
|
||||
fixed32 field_k = 207;
|
||||
|
||||
enum SomeEnum {
|
||||
UNKNOWN = 0;
|
||||
POSITIVE = 1;
|
||||
NEGATIVE = -1;
|
||||
}
|
||||
SomeEnum field_h = 300;
|
||||
enum SomeEnum {
|
||||
UNKNOWN = 0;
|
||||
POSITIVE = 1;
|
||||
NEGATIVE = -1;
|
||||
}
|
||||
SomeEnum field_h = 300;
|
||||
}
|
||||
|
||||
message RepPrimitives {
|
||||
repeated bytes field_a = 1;
|
||||
repeated string field_b = 2;
|
||||
repeated int32 field_c = 3;
|
||||
repeated uint32 field_d = 4;
|
||||
repeated int64 field_e = 5;
|
||||
repeated uint64 field_f = 6;
|
||||
repeated bytes field_a = 1;
|
||||
repeated string field_b = 2;
|
||||
repeated int32 field_c = 3;
|
||||
repeated uint32 field_d = 4;
|
||||
repeated int64 field_e = 5;
|
||||
repeated uint64 field_f = 6;
|
||||
repeated uint64 field_fu = 7 [ packed = false ];
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ import (
|
|||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var (
|
||||
protowirePackage = protogen.GoImportPath("google.golang.org/protobuf/encoding/protowire")
|
||||
binaryPackage = protogen.GoImportPath("encoding/binary")
|
||||
)
|
||||
|
||||
func main() {
|
||||
protogen.Options{}.Run(func(gen *protogen.Plugin) error {
|
||||
for _, f := range gen.Files {
|
||||
|
@ -62,7 +67,7 @@ func emitMessage(g *protogen.GeneratedFile, msg *protogen.Message) {
|
|||
g.P("if x == nil { return 0 }")
|
||||
if len(fs) != 0 {
|
||||
for _, f := range fs {
|
||||
if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble {
|
||||
if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble && !(f.Desc.Kind() == protoreflect.Uint64Kind && !f.Desc.IsPacked()) {
|
||||
g.P("var n int")
|
||||
break
|
||||
}
|
||||
|
@ -140,9 +145,19 @@ func emitFieldSize(g *protogen.GeneratedFile, f *protogen.Field) {
|
|||
}
|
||||
|
||||
switch {
|
||||
case f.Desc.IsList() && f.Desc.Kind() == protoreflect.MessageKind:
|
||||
case f.Desc.IsList() && (f.Desc.Kind() == protoreflect.MessageKind || f.Desc.Kind() == protoreflect.Uint64Kind && !f.Desc.IsPacked()):
|
||||
g.P("for i := range ", name, "{")
|
||||
g.P("size += proto.NestedStructureSize(", f.Desc.Number(), ", ", name, "[i])")
|
||||
if f.Desc.Kind() == protoreflect.MessageKind {
|
||||
g.P("size += proto.NestedStructureSize(", f.Desc.Number(), ", ", name, "[i])")
|
||||
} else {
|
||||
if f.Desc.Kind() != protoreflect.Uint64Kind {
|
||||
panic("only uint64 unpacked primitive is supported")
|
||||
}
|
||||
|
||||
g.P("size += ", protowirePackage.Ident("SizeGroup"), "(",
|
||||
protowirePackage.Ident("Number"), "(", f.Desc.Number(), "), ",
|
||||
protowirePackage.Ident("SizeVarint"), "(", name, "[i]))")
|
||||
}
|
||||
g.P("}")
|
||||
case f.Desc.IsList():
|
||||
if m.RepeatedDouble {
|
||||
|
@ -177,9 +192,22 @@ func emitFieldMarshal(g *protogen.GeneratedFile, f *protogen.Field) {
|
|||
prefix = "Repeated" + m.Prefix
|
||||
}
|
||||
switch {
|
||||
case f.Desc.IsList() && f.Desc.Kind() == protoreflect.MessageKind:
|
||||
case f.Desc.IsList() && (f.Desc.Kind() == protoreflect.MessageKind || f.Desc.Kind() == protoreflect.Uint64Kind && !f.Desc.IsPacked()):
|
||||
g.P("for i := range ", name, "{")
|
||||
g.P("offset += proto.NestedStructureMarshal(", f.Desc.Number(), ", buf[offset:], ", name, "[i])")
|
||||
if f.Desc.Kind() == protoreflect.MessageKind {
|
||||
g.P("offset += proto.NestedStructureMarshal(", f.Desc.Number(), ", buf[offset:], ", name, "[i])")
|
||||
} else {
|
||||
if f.Desc.Kind() != protoreflect.Uint64Kind {
|
||||
panic("only uint64 unpacked primitive is supported")
|
||||
}
|
||||
g.P("{")
|
||||
g.P("prefix := ", protowirePackage.Ident("EncodeTag"), "(",
|
||||
protowirePackage.Ident("Number"), "(", f.Desc.Number(), "), ",
|
||||
protowirePackage.Ident("VarintType"), ")")
|
||||
g.P("offset += ", binaryPackage.Ident("PutUvarint"), "(buf[offset:], uint64(prefix))")
|
||||
g.P("offset += ", binaryPackage.Ident("PutUvarint"), "(buf[offset:], ", name, "[i])")
|
||||
g.P("}")
|
||||
}
|
||||
g.P("}")
|
||||
case f.Desc.IsList():
|
||||
g.P("offset += proto.Repeated", m.Prefix, "Marshal(", f.Desc.Number(), ", buf[offset:], ", name, ")")
|
||||
|
|
Loading…
Reference in a new issue