forked from TrueCloudLab/frostfs-api-go
Compare commits
1 Commits
master
...
debug/1/si
Author | SHA1 | Date |
---|---|---|
Airat Arifullin | 799def09a7 |
|
@ -1,21 +0,0 @@
|
|||
name: DCO action
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
dco:
|
||||
name: DCO
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Run commit format checker
|
||||
uses: https://git.frostfs.info/TrueCloudLab/dco-go@v2
|
||||
with:
|
||||
from: 'origin/${{ github.event.pull_request.base.ref }}'
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: accounting/grpc/service.proto
|
||||
|
||||
package accounting
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.23.4
|
||||
// - protoc v3.21.9
|
||||
// source: accounting/grpc/service.proto
|
||||
|
||||
package accounting
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: accounting/grpc/types.proto
|
||||
|
||||
package accounting
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: acl/grpc/types.proto
|
||||
|
||||
package acl
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: audit/grpc/types.proto
|
||||
|
||||
package audit
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: container/grpc/service.proto
|
||||
|
||||
package container
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.23.4
|
||||
// - protoc v3.21.9
|
||||
// source: container/grpc/service.proto
|
||||
|
||||
package container
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: container/grpc/types.proto
|
||||
|
||||
package container
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module git.frostfs.info/TrueCloudLab/frostfs-api-go/v2
|
||||
|
||||
go 1.20
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package random
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
// Uint32 returns random uint32 value [0, max).
|
||||
func Uint32(max uint32) uint32 {
|
||||
return rand.Uint32() % max
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: lock/grpc/types.proto
|
||||
|
||||
package lock
|
||||
|
|
|
@ -198,7 +198,6 @@ func (p *PlacementPolicy) ToGRPCMessage() grpc.Message {
|
|||
m.SetSelectors(SelectorsToGRPC(p.selectors))
|
||||
m.SetReplicas(ReplicasToGRPC(p.replicas))
|
||||
m.SetContainerBackupFactor(p.backupFactor)
|
||||
m.SetUnique(p.unique)
|
||||
}
|
||||
|
||||
return m
|
||||
|
@ -229,8 +228,6 @@ func (p *PlacementPolicy) FromGRPCMessage(m grpc.Message) error {
|
|||
|
||||
p.backupFactor = v.GetContainerBackupFactor()
|
||||
|
||||
p.unique = v.GetUnique()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: netmap/grpc/service.proto
|
||||
|
||||
package netmap
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.23.4
|
||||
// - protoc v3.21.9
|
||||
// source: netmap/grpc/service.proto
|
||||
|
||||
package netmap
|
||||
|
|
|
@ -20,11 +20,6 @@ func (m *PlacementPolicy) SetFilters(v []*Filter) {
|
|||
m.Filters = v
|
||||
}
|
||||
|
||||
// SetUnique of placement policy.
|
||||
func (m *PlacementPolicy) SetUnique(unique bool) {
|
||||
m.Unique = unique
|
||||
}
|
||||
|
||||
// SetName of placement filter.
|
||||
func (m *Filter) SetName(v string) {
|
||||
m.Name = v
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc v3.12.4
|
||||
// source: netmap/grpc/types.proto
|
||||
|
||||
package netmap
|
||||
|
|
|
@ -65,10 +65,6 @@ func (f *Filter) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (f *Filter) StableSize() (size int) {
|
||||
if f == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.StringSize(nameFilterField, f.name)
|
||||
size += protoutil.StringSize(keyFilterField, f.key)
|
||||
size += protoutil.EnumSize(opFilterField, int32(f.op))
|
||||
|
@ -105,10 +101,6 @@ func (s *Selector) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (s *Selector) StableSize() (size int) {
|
||||
if s == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.StringSize(nameSelectorField, s.name)
|
||||
size += protoutil.UInt32Size(countSelectorField, s.count)
|
||||
size += protoutil.EnumSize(countSelectorField, int32(s.clause))
|
||||
|
@ -140,10 +132,6 @@ func (r *Replica) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (r *Replica) StableSize() (size int) {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.UInt32Size(countReplicaField, r.count)
|
||||
size += protoutil.StringSize(selectorReplicaField, r.selector)
|
||||
|
||||
|
@ -185,10 +173,6 @@ func (p *PlacementPolicy) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (p *PlacementPolicy) StableSize() (size int) {
|
||||
if p == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
for i := range p.replicas {
|
||||
size += protoutil.NestedStructureSize(replicasPolicyField, &p.replicas[i])
|
||||
}
|
||||
|
|
|
@ -102,7 +102,6 @@ func GeneratePlacementPolicy(empty bool) *netmap.PlacementPolicy {
|
|||
m.SetFilters(GenerateFilters(false))
|
||||
m.SetSelectors(GenerateSelectors(false))
|
||||
m.SetReplicas(GenerateReplicas(false))
|
||||
m.SetUnique(true)
|
||||
}
|
||||
|
||||
return m
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc v3.21.9
|
||||
// source: object/grpc/service.proto
|
||||
|
||||
package object
|
||||
|
@ -1592,16 +1592,16 @@ type PutRequest_Body_Init struct {
|
|||
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
// Object's Header
|
||||
Header *Header `protobuf:"bytes,3,opt,name=header,proto3" json:"header,omitempty"`
|
||||
// Number of copies of the object to store within the RPC call. By
|
||||
// default, object is processed according to the container's placement
|
||||
// policy. Can be one of:
|
||||
// Number of copies of the object to store within the RPC call. By default,
|
||||
// object is processed according to the container's placement policy.
|
||||
// Can be one of:
|
||||
// 1. A single number; applied to the whole request and is treated as
|
||||
// a minimal number of nodes that must store an object to complete the
|
||||
// request successfully.
|
||||
// 2. An ordered array; every number is treated as a minimal number of
|
||||
// nodes in a corresponding placement vector that must store an object
|
||||
// to complete the request successfully. The length MUST equal the
|
||||
// placement vectors number, otherwise request is considered malformed.
|
||||
// to complete the request successfully. The length MUST equal the placement
|
||||
// vectors number, otherwise request is considered malformed.
|
||||
CopiesNumber []uint32 `protobuf:"varint,4,rep,packed,name=copies_number,json=copiesNumber,proto3" json:"copies_number,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -2049,11 +2049,11 @@ func (x *SearchRequest_Body) GetFilters() []*SearchRequest_Body_Filter {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Filter structure checks if the object header field or the attribute
|
||||
// content matches a value.
|
||||
// Filter structure checks if the object header field or the attribute content
|
||||
// matches a value.
|
||||
//
|
||||
// If no filters are set, search request will return all objects of the
|
||||
// container, including Regular object and Tombstone
|
||||
// container, including Regular object, Tombstones and Storage Group
|
||||
// objects. Most human users expect to get only object they can directly
|
||||
// work with. In that case, `$Object:ROOT` filter should be used.
|
||||
//
|
||||
|
@ -2088,11 +2088,11 @@ func (x *SearchRequest_Body) GetFilters() []*SearchRequest_Body_Filter {
|
|||
// properties:
|
||||
//
|
||||
// - $Object:ROOT \
|
||||
// Returns only `REGULAR` type objects that are not split or that are the
|
||||
// top level root objects in a split hierarchy. This includes objects not
|
||||
// Returns only `REGULAR` type objects that are not split or that are the top
|
||||
// level root objects in a split hierarchy. This includes objects not
|
||||
// present physically, like large objects split into smaller objects
|
||||
// without a separate top-level root object. Objects of other types like
|
||||
// Locks and Tombstones will not be shown. This filter may be
|
||||
// StorageGroups and Tombstones will not be shown. This filter may be
|
||||
// useful for listing objects like `ls` command of some virtual file
|
||||
// system. This filter is activated if the `key` exists, disregarding the
|
||||
// value and matcher type.
|
||||
|
@ -2101,8 +2101,8 @@ func (x *SearchRequest_Body) GetFilters() []*SearchRequest_Body_Filter {
|
|||
// activated if the `key` exists, disregarding the value and matcher type.
|
||||
//
|
||||
// Note: using filters with a key with prefix `$Object:` and match type
|
||||
// `NOT_PRESENT `is not recommended since this is not a cross-version
|
||||
// approach. Behavior when processing this kind of filters is undefined.
|
||||
// `NOT_PRESENT `is not recommended since this is not a cross-version approach.
|
||||
// Behavior when processing this kind of filters is undefined.
|
||||
type SearchRequest_Body_Filter struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.23.4
|
||||
// - protoc v3.21.9
|
||||
// source: object/grpc/service.proto
|
||||
|
||||
package object
|
||||
|
@ -34,11 +34,11 @@ const (
|
|||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ObjectServiceClient interface {
|
||||
// Receive full object structure, including Headers and payload. Response uses
|
||||
// gRPC stream. First response message carries the object with the requested
|
||||
// address. Chunk messages are parts of the object's payload if it is needed.
|
||||
// All messages, except the first one, carry payload chunks. The requested
|
||||
// object can be restored by concatenation of object message payload and all
|
||||
// chunks keeping the receiving order.
|
||||
// gRPC stream. First response message carries the object with the requested address.
|
||||
// Chunk messages are parts of the object's payload if it is needed. All
|
||||
// messages, except the first one, carry payload chunks. The requested object can
|
||||
// be restored by concatenation of object message payload and all chunks
|
||||
// keeping the receiving order.
|
||||
//
|
||||
// Extended headers can change `Get` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
|
@ -47,10 +47,9 @@ type ObjectServiceClient interface {
|
|||
// calculation.
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH`
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or the latest one
|
||||
// otherwise) of Network Map to find an object until the depth limit is
|
||||
// reached.
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH` (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or
|
||||
// the latest one otherwise) of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
//
|
||||
// Please refer to detailed `XHeader` description.
|
||||
//
|
||||
|
@ -91,16 +90,15 @@ type ObjectServiceClient interface {
|
|||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// placement of an object of type TOMBSTONE that includes at least one
|
||||
// locked object is prohibited;
|
||||
// placement of an object of type TOMBSTONE that includes at least one locked
|
||||
// object is prohibited;
|
||||
// - **LOCK_NON_REGULAR_OBJECT** (2051, SECTION_OBJECT): \
|
||||
// placement of an object of type LOCK that includes at least one object of
|
||||
// type other than REGULAR is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has
|
||||
// (for trusted object preparation) session private key does not exist or has
|
||||
//
|
||||
// been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
|
@ -123,9 +121,6 @@ type ObjectServiceClient interface {
|
|||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// delete access to the object is denied;
|
||||
// - **OBJECT_NOT_FOUND** (2049, SECTION_OBJECT): \
|
||||
// the object could not be deleted because it has not been \
|
||||
// found within the container;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// deleting a locked object is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
|
@ -185,8 +180,8 @@ type ObjectServiceClient interface {
|
|||
Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (ObjectService_SearchClient, error)
|
||||
// Get byte range of data payload. Range is set as an (offset, length) tuple.
|
||||
// Like in `Get` method, the response uses gRPC stream. Requested range can be
|
||||
// restored by concatenation of all received payload chunks keeping the
|
||||
// receiving order.
|
||||
// restored by concatenation of all received payload chunks keeping the receiving
|
||||
// order.
|
||||
//
|
||||
// Extended headers can change `GetRange` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
|
@ -250,8 +245,9 @@ type ObjectServiceClient interface {
|
|||
// provided session token has expired.
|
||||
GetRangeHash(ctx context.Context, in *GetRangeHashRequest, opts ...grpc.CallOption) (*GetRangeHashResponse, error)
|
||||
// Put the prepared object into container.
|
||||
// `ContainerID`, `ObjectID`, `OwnerID`, `PayloadHash` and `PayloadLength` of
|
||||
// an object MUST be set.
|
||||
// `ContainerID`, `ObjectID` and `OwnerID` of an object
|
||||
// MUST be set. Session token MUST be obtained before `PUT SINGLE` operation (see
|
||||
// session package).
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
|
@ -268,16 +264,15 @@ type ObjectServiceClient interface {
|
|||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// placement of an object of type TOMBSTONE that includes at least one
|
||||
// locked object is prohibited;
|
||||
// placement of an object of type TOMBSTONE that includes at least one locked
|
||||
// object is prohibited;
|
||||
// - **LOCK_NON_REGULAR_OBJECT** (2051, SECTION_OBJECT): \
|
||||
// placement of an object of type LOCK that includes at least one object of
|
||||
// type other than REGULAR is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has
|
||||
// (for trusted object preparation) session private key does not exist or has
|
||||
//
|
||||
// been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
|
@ -464,11 +459,11 @@ func (c *objectServiceClient) PutSingle(ctx context.Context, in *PutSingleReques
|
|||
// for forward compatibility
|
||||
type ObjectServiceServer interface {
|
||||
// Receive full object structure, including Headers and payload. Response uses
|
||||
// gRPC stream. First response message carries the object with the requested
|
||||
// address. Chunk messages are parts of the object's payload if it is needed.
|
||||
// All messages, except the first one, carry payload chunks. The requested
|
||||
// object can be restored by concatenation of object message payload and all
|
||||
// chunks keeping the receiving order.
|
||||
// gRPC stream. First response message carries the object with the requested address.
|
||||
// Chunk messages are parts of the object's payload if it is needed. All
|
||||
// messages, except the first one, carry payload chunks. The requested object can
|
||||
// be restored by concatenation of object message payload and all chunks
|
||||
// keeping the receiving order.
|
||||
//
|
||||
// Extended headers can change `Get` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
|
@ -477,10 +472,9 @@ type ObjectServiceServer interface {
|
|||
// calculation.
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH`
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or the latest one
|
||||
// otherwise) of Network Map to find an object until the depth limit is
|
||||
// reached.
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH` (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or
|
||||
// the latest one otherwise) of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
//
|
||||
// Please refer to detailed `XHeader` description.
|
||||
//
|
||||
|
@ -521,16 +515,15 @@ type ObjectServiceServer interface {
|
|||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// placement of an object of type TOMBSTONE that includes at least one
|
||||
// locked object is prohibited;
|
||||
// placement of an object of type TOMBSTONE that includes at least one locked
|
||||
// object is prohibited;
|
||||
// - **LOCK_NON_REGULAR_OBJECT** (2051, SECTION_OBJECT): \
|
||||
// placement of an object of type LOCK that includes at least one object of
|
||||
// type other than REGULAR is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has
|
||||
// (for trusted object preparation) session private key does not exist or has
|
||||
//
|
||||
// been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
|
@ -553,9 +546,6 @@ type ObjectServiceServer interface {
|
|||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// delete access to the object is denied;
|
||||
// - **OBJECT_NOT_FOUND** (2049, SECTION_OBJECT): \
|
||||
// the object could not be deleted because it has not been \
|
||||
// found within the container;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// deleting a locked object is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
|
@ -615,8 +605,8 @@ type ObjectServiceServer interface {
|
|||
Search(*SearchRequest, ObjectService_SearchServer) error
|
||||
// Get byte range of data payload. Range is set as an (offset, length) tuple.
|
||||
// Like in `Get` method, the response uses gRPC stream. Requested range can be
|
||||
// restored by concatenation of all received payload chunks keeping the
|
||||
// receiving order.
|
||||
// restored by concatenation of all received payload chunks keeping the receiving
|
||||
// order.
|
||||
//
|
||||
// Extended headers can change `GetRange` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
|
@ -680,8 +670,9 @@ type ObjectServiceServer interface {
|
|||
// provided session token has expired.
|
||||
GetRangeHash(context.Context, *GetRangeHashRequest) (*GetRangeHashResponse, error)
|
||||
// Put the prepared object into container.
|
||||
// `ContainerID`, `ObjectID`, `OwnerID`, `PayloadHash` and `PayloadLength` of
|
||||
// an object MUST be set.
|
||||
// `ContainerID`, `ObjectID` and `OwnerID` of an object
|
||||
// MUST be set. Session token MUST be obtained before `PUT SINGLE` operation (see
|
||||
// session package).
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
|
@ -698,16 +689,15 @@ type ObjectServiceServer interface {
|
|||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **LOCKED** (2050, SECTION_OBJECT): \
|
||||
// placement of an object of type TOMBSTONE that includes at least one
|
||||
// locked object is prohibited;
|
||||
// placement of an object of type TOMBSTONE that includes at least one locked
|
||||
// object is prohibited;
|
||||
// - **LOCK_NON_REGULAR_OBJECT** (2051, SECTION_OBJECT): \
|
||||
// placement of an object of type LOCK that includes at least one object of
|
||||
// type other than REGULAR is prohibited;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has
|
||||
// (for trusted object preparation) session private key does not exist or has
|
||||
//
|
||||
// been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc v3.21.9
|
||||
// source: object/grpc/types.proto
|
||||
|
||||
package object
|
||||
|
@ -23,12 +23,13 @@ const (
|
|||
)
|
||||
|
||||
// Type of the object payload content. Only `REGULAR` type objects can be split,
|
||||
// hence `TOMBSTONE` and `LOCK` payload is limited by the
|
||||
// maximum object size.
|
||||
// hence `TOMBSTONE`, `STORAGE_GROUP` and `LOCK` payload is limited by the maximum
|
||||
// object size.
|
||||
//
|
||||
// String presentation of object type is the same as definition:
|
||||
// * REGULAR
|
||||
// * TOMBSTONE
|
||||
// * STORAGE_GROUP
|
||||
// * LOCK
|
||||
type ObjectType int32
|
||||
|
||||
|
@ -37,6 +38,8 @@ const (
|
|||
ObjectType_REGULAR ObjectType = 0
|
||||
// Used internally to identify deleted objects
|
||||
ObjectType_TOMBSTONE ObjectType = 1
|
||||
// StorageGroup information
|
||||
ObjectType_STORAGE_GROUP ObjectType = 2
|
||||
// Object lock
|
||||
ObjectType_LOCK ObjectType = 3
|
||||
)
|
||||
|
@ -46,12 +49,14 @@ var (
|
|||
ObjectType_name = map[int32]string{
|
||||
0: "REGULAR",
|
||||
1: "TOMBSTONE",
|
||||
2: "STORAGE_GROUP",
|
||||
3: "LOCK",
|
||||
}
|
||||
ObjectType_value = map[string]int32{
|
||||
"REGULAR": 0,
|
||||
"TOMBSTONE": 1,
|
||||
"LOCK": 3,
|
||||
"REGULAR": 0,
|
||||
"TOMBSTONE": 1,
|
||||
"STORAGE_GROUP": 2,
|
||||
"LOCK": 3,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -391,8 +396,8 @@ func (x *Header) GetSplit() *Header_Split {
|
|||
}
|
||||
|
||||
// Object structure. Object is immutable and content-addressed. It means
|
||||
// `ObjectID` will change if the header or the payload changes. It's calculated
|
||||
// as a hash of header field which contains hash of the object's payload.
|
||||
// `ObjectID` will change if the header or the payload changes. It's calculated as a
|
||||
// hash of header field which contains hash of the object's payload.
|
||||
//
|
||||
// For non-regular object types payload format depends on object type specified
|
||||
// in the header.
|
||||
|
@ -473,8 +478,8 @@ func (x *Object) GetPayload() []byte {
|
|||
|
||||
// Meta information of split hierarchy for object assembly. With the last part
|
||||
// one can traverse linked list of split hierarchy back to the first part and
|
||||
// assemble the original object. With a linking object one can assemble an
|
||||
// object right from the object parts.
|
||||
// assemble the original object. With a linking object one can assemble an object
|
||||
// right from the object parts.
|
||||
type SplitInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -551,8 +556,8 @@ func (x *SplitInfo) GetLink() *grpc.ObjectID {
|
|||
// Objects with duplicated attribute names or attributes with empty values
|
||||
// will be considered invalid.
|
||||
//
|
||||
// There are some "well-known" attributes starting with `__SYSTEM__`
|
||||
// (`__NEOFS__` is deprecated) prefix that affect system behaviour:
|
||||
// There are some "well-known" attributes starting with `__SYSTEM__` (`__NEOFS__` is deprecated) prefix
|
||||
// that affect system behaviour:
|
||||
//
|
||||
// - [ __SYSTEM__UPLOAD_ID ] \
|
||||
// (`__NEOFS__UPLOAD_ID` is deprecated) \
|
||||
|
@ -864,24 +869,25 @@ var file_object_grpc_types_proto_rawDesc = []byte{
|
|||
0x61, 0x73, 0x74, 0x50, 0x61, 0x72, 0x74, 0x12, 0x2c, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76,
|
||||
0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x52,
|
||||
0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x2a, 0x32, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54,
|
||||
0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x2a, 0x45, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x45, 0x47, 0x55, 0x4c, 0x41, 0x52, 0x10, 0x00,
|
||||
0x12, 0x0d, 0x0a, 0x09, 0x54, 0x4f, 0x4d, 0x42, 0x53, 0x54, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12,
|
||||
0x08, 0x0a, 0x04, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x03, 0x2a, 0x73, 0x0a, 0x09, 0x4d, 0x61, 0x74,
|
||||
0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x5f,
|
||||
0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44,
|
||||
0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x45, 0x51, 0x55,
|
||||
0x41, 0x4c, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x4e,
|
||||
0x4f, 0x54, 0x5f, 0x45, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x4f,
|
||||
0x54, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43,
|
||||
0x4f, 0x4d, 0x4d, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x10, 0x04, 0x42, 0x61,
|
||||
0x5a, 0x42, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e,
|
||||
0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f,
|
||||
0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d, 0x67, 0x6f, 0x2f, 0x76,
|
||||
0x32, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x6f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0xaa, 0x02, 0x1a, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x53,
|
||||
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x11, 0x0a, 0x0d, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50,
|
||||
0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x4c, 0x4f, 0x43, 0x4b, 0x10, 0x03, 0x2a, 0x73, 0x0a, 0x09,
|
||||
0x4d, 0x61, 0x74, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x4d, 0x41, 0x54,
|
||||
0x43, 0x48, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
|
||||
0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f,
|
||||
0x45, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x52, 0x49, 0x4e,
|
||||
0x47, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x45, 0x51, 0x55, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x0f, 0x0a,
|
||||
0x0b, 0x4e, 0x4f, 0x54, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x11,
|
||||
0x0a, 0x0d, 0x43, 0x4f, 0x4d, 0x4d, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x10,
|
||||
0x04, 0x42, 0x61, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73,
|
||||
0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x4c,
|
||||
0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d, 0x67,
|
||||
0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63,
|
||||
0x3b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0xaa, 0x02, 0x1a, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69,
|
||||
0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x4f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package objecttest
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/internal/random"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
||||
|
@ -188,7 +186,7 @@ func GenerateGetResponseBody(empty bool) *object.GetResponseBody {
|
|||
m := new(object.GetResponseBody)
|
||||
|
||||
if !empty {
|
||||
switch randomInt(3) {
|
||||
switch random.Uint32(3) {
|
||||
case 0:
|
||||
m.SetObjectPart(GenerateGetObjectPartInit(false))
|
||||
case 1:
|
||||
|
@ -242,7 +240,7 @@ func GeneratePutRequestBody(empty bool) *object.PutRequestBody {
|
|||
m := new(object.PutRequestBody)
|
||||
|
||||
if !empty {
|
||||
switch randomInt(2) {
|
||||
switch random.Uint32(2) {
|
||||
case 0:
|
||||
m.SetObjectPart(GeneratePutObjectPartInit(false))
|
||||
case 1:
|
||||
|
@ -364,7 +362,7 @@ func GenerateHeadResponseBody(empty bool) *object.HeadResponseBody {
|
|||
m := new(object.HeadResponseBody)
|
||||
|
||||
if !empty {
|
||||
switch randomInt(3) {
|
||||
switch random.Uint32(3) {
|
||||
case 0:
|
||||
m.SetHeaderPart(GenerateHeaderWithSignature(false))
|
||||
case 1:
|
||||
|
@ -526,7 +524,7 @@ func GenerateGetRangeResponseBody(empty bool) *object.GetRangeResponseBody {
|
|||
m := new(object.GetRangeResponseBody)
|
||||
|
||||
if !empty {
|
||||
switch randomInt(2) {
|
||||
switch random.Uint32(2) {
|
||||
case 0:
|
||||
m.SetRangePart(GenerateGetRangePartChunk(false))
|
||||
case 1:
|
||||
|
@ -644,7 +642,3 @@ func GeneratePutSingleResponse(empty bool) *object.PutSingleResponse {
|
|||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
return m
|
||||
}
|
||||
|
||||
func randomInt(n int) int {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(n)
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ type PutSingleResponse struct {
|
|||
const (
|
||||
TypeRegular Type = iota
|
||||
TypeTombstone
|
||||
_
|
||||
TypeStorageGroup
|
||||
TypeLock
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: refs/grpc/types.proto
|
||||
|
||||
package refs
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -117,7 +116,7 @@ func (o *ObjectID) StableSize() int {
|
|||
// ObjectIDNestedListMarshal writes protobuf repeated ObjectID field
|
||||
// with fNum number to buf.
|
||||
func ObjectIDNestedListMarshal(fNum int64, buf []byte, ids []ObjectID) (off int) {
|
||||
prefix := protowire.EncodeTag(protowire.Number(fNum), protowire.BytesType)
|
||||
prefix, _ := proto.NestedStructurePrefix(fNum)
|
||||
for i := range ids {
|
||||
off += binary.PutUvarint(buf[off:], prefix)
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ type jsonMessage interface {
|
|||
|
||||
type binaryMessage interface {
|
||||
StableMarshal([]byte) []byte
|
||||
StableSize() int
|
||||
Unmarshal([]byte) error
|
||||
}
|
||||
|
||||
|
@ -54,11 +53,6 @@ func TestRPCMessage(t *testing.T, msgGens ...func(empty bool) message.Message) {
|
|||
}
|
||||
|
||||
if bm, ok := msg.(binaryMessage); ok {
|
||||
t.Run(fmt.Sprintf("%T.StableSize() does no allocations", bm), func(t *testing.T) {
|
||||
require.Zero(t, testing.AllocsPerRun(1000, func() {
|
||||
_ = bm.StableSize()
|
||||
}))
|
||||
})
|
||||
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
|
||||
data := bm.StableMarshal(nil)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: session/grpc/service.proto
|
||||
|
||||
package session
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc v4.23.4
|
||||
// - protoc v3.21.9
|
||||
// source: session/grpc/service.proto
|
||||
|
||||
package session
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: session/grpc/types.proto
|
||||
|
||||
package session
|
||||
|
|
|
@ -211,7 +211,7 @@ func (c *ObjectSessionContext) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
offset := proto.EnumMarshal(objectCtxVerbField, buf, int32(c.verb))
|
||||
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], objectSessionContextTarget{
|
||||
proto.NestedStructureMarshal(objectCtxTargetField, buf[offset:], &objectSessionContextTarget{
|
||||
cnr: c.cnr,
|
||||
objs: c.objs,
|
||||
})
|
||||
|
@ -225,7 +225,7 @@ func (c *ObjectSessionContext) StableSize() (size int) {
|
|||
}
|
||||
|
||||
size += proto.EnumSize(objectCtxVerbField, int32(c.verb))
|
||||
size += proto.NestedStructureSize(objectCtxTargetField, objectSessionContextTarget{
|
||||
size += proto.NestedStructureSize(objectCtxTargetField, &objectSessionContextTarget{
|
||||
cnr: c.cnr,
|
||||
objs: c.objs,
|
||||
})
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package sessiontest
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
acltest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/acl/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/internal/random"
|
||||
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session"
|
||||
statustest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/test"
|
||||
|
@ -169,7 +167,7 @@ func GenerateSessionTokenBody(empty bool) *session.TokenBody {
|
|||
m.SetOwnerID(refstest.GenerateOwnerID(false))
|
||||
m.SetLifetime(GenerateTokenLifetime(false))
|
||||
|
||||
switch randomInt(2) {
|
||||
switch random.Uint32(2) {
|
||||
case 0:
|
||||
m.SetContext(GenerateObjectSessionContext(false))
|
||||
case 1:
|
||||
|
@ -238,7 +236,3 @@ func GenerateXHeaders(empty bool) []session.XHeader {
|
|||
|
||||
return xs
|
||||
}
|
||||
|
||||
func randomInt(n int) int {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(n)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ func signServiceRequest(key *ecdsa.PrivateKey, v serviceRequest) error {
|
|||
if err := signMessageParts(key, body, meta, header, header != nil, result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := verifyServiceMessagePart(body, result.GetBodySignature); err != nil {
|
||||
return fmt.Errorf("DEBUG POINT: could not verify body: %w", err)
|
||||
}
|
||||
result.SetOrigin(header)
|
||||
v.SetVerificationHeader(result)
|
||||
return nil
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: status/grpc/types.proto
|
||||
|
||||
package status
|
||||
|
|
|
@ -30,10 +30,6 @@ func (x *Detail) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (x *Detail) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.UInt32Size(detailIDFNum, x.id)
|
||||
size += protoutil.BytesSize(detailValueFNum, x.val)
|
||||
|
||||
|
@ -73,10 +69,6 @@ func (x *Status) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
func (x *Status) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.UInt32Size(statusCodeFNum, CodeToGRPC(x.code))
|
||||
size += protoutil.StringSize(statusMsgFNum, x.msg)
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package storagegroup
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
sg "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc"
|
||||
)
|
||||
|
||||
func (s *StorageGroup) ToGRPCMessage() grpc.Message {
|
||||
m := new(sg.StorageGroup)
|
||||
|
||||
if s != nil {
|
||||
m = new(sg.StorageGroup)
|
||||
|
||||
m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members))
|
||||
//nolint:staticcheck
|
||||
m.SetExpirationEpoch(s.exp)
|
||||
m.SetValidationDataSize(s.size)
|
||||
m.SetValidationHash(s.hash.ToGRPCMessage().(*refsGRPC.Checksum))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (s *StorageGroup) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*sg.StorageGroup)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
hash := v.GetValidationHash()
|
||||
if hash == nil {
|
||||
s.hash = nil
|
||||
} else {
|
||||
if s.hash == nil {
|
||||
s.hash = new(refs.Checksum)
|
||||
}
|
||||
|
||||
err = s.hash.FromGRPCMessage(hash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//nolint:staticcheck
|
||||
s.exp = v.GetExpirationEpoch()
|
||||
s.size = v.GetValidationDataSize()
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package storagegroup
|
||||
|
||||
import (
|
||||
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
)
|
||||
|
||||
// SetValidationDataSize sets the total size of the payloads of the storage group.
|
||||
func (m *StorageGroup) SetValidationDataSize(v uint64) {
|
||||
m.ValidationDataSize = v
|
||||
}
|
||||
|
||||
// SetValidationHash sets total homomorphic hash of the storage group payloads.
|
||||
func (m *StorageGroup) SetValidationHash(v *refs.Checksum) {
|
||||
m.ValidationHash = v
|
||||
}
|
||||
|
||||
// SetExpirationEpoch sets number of the last epoch of the storage group lifetime.
|
||||
//
|
||||
// Deprecated: do not use, `expiration_epoch` field is deprecated in protocol.
|
||||
func (m *StorageGroup) SetExpirationEpoch(v uint64) {
|
||||
m.ExpirationEpoch = v
|
||||
}
|
||||
|
||||
// SetMembers sets list of the identifiers of the storage group members.
|
||||
func (m *StorageGroup) SetMembers(v []*refs.ObjectID) {
|
||||
m.Members = v
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: storagegroup/grpc/types.proto
|
||||
|
||||
package storagegroup
|
||||
|
||||
import (
|
||||
grpc "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// StorageGroup keeps verification information for Data Audit sessions. Objects
|
||||
// that require paid storage guarantees are gathered in `StorageGroups` with
|
||||
// additional information used for the proof of storage. `StorageGroup` only
|
||||
// contains objects from the same container.
|
||||
//
|
||||
// Being an object payload, StorageGroup may have expiration Epoch set with
|
||||
// `__SYSTEM__EXPIRATION_EPOCH` (`__NEOFS__EXPIRATION_EPOCH` is deprecated) well-known attribute. When expired, StorageGroup
|
||||
// will be ignored by InnerRing nodes during Data Audit cycles and will be
|
||||
// deleted by Storage Nodes.
|
||||
type StorageGroup struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Total size of the payloads of objects in the storage group
|
||||
ValidationDataSize uint64 `protobuf:"varint,1,opt,name=validation_data_size,json=validationDataSize,proto3" json:"validation_data_size,omitempty"`
|
||||
// Homomorphic hash from the concatenation of the payloads of the storage
|
||||
// group members. The order of concatenation is the same as the order of the
|
||||
// members in the `members` field.
|
||||
ValidationHash *grpc.Checksum `protobuf:"bytes,2,opt,name=validation_hash,json=validationHash,proto3" json:"validation_hash,omitempty"`
|
||||
// DEPRECATED. Last NeoFS epoch number of the storage group lifetime
|
||||
//
|
||||
// Deprecated: Do not use.
|
||||
ExpirationEpoch uint64 `protobuf:"varint,3,opt,name=expiration_epoch,json=expirationEpoch,proto3" json:"expiration_epoch,omitempty"`
|
||||
// Strictly ordered list of storage group member objects. Members MUST be unique
|
||||
Members []*grpc.ObjectID `protobuf:"bytes,4,rep,name=members,proto3" json:"members,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StorageGroup) Reset() {
|
||||
*x = StorageGroup{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_storagegroup_grpc_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *StorageGroup) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StorageGroup) ProtoMessage() {}
|
||||
|
||||
func (x *StorageGroup) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_storagegroup_grpc_types_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StorageGroup.ProtoReflect.Descriptor instead.
|
||||
func (*StorageGroup) Descriptor() ([]byte, []int) {
|
||||
return file_storagegroup_grpc_types_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *StorageGroup) GetValidationDataSize() uint64 {
|
||||
if x != nil {
|
||||
return x.ValidationDataSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageGroup) GetValidationHash() *grpc.Checksum {
|
||||
if x != nil {
|
||||
return x.ValidationHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated: Do not use.
|
||||
func (x *StorageGroup) GetExpirationEpoch() uint64 {
|
||||
if x != nil {
|
||||
return x.ExpirationEpoch
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *StorageGroup) GetMembers() []*grpc.ObjectID {
|
||||
if x != nil {
|
||||
return x.Members
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_storagegroup_grpc_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_storagegroup_grpc_types_proto_rawDesc = []byte{
|
||||
0x0a, 0x1d, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x67,
|
||||
0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x16, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61,
|
||||
0x67, 0x65, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x1a, 0x15, 0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72,
|
||||
0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe6,
|
||||
0x01, 0x0a, 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12,
|
||||
0x30, 0x0a, 0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61,
|
||||
0x74, 0x61, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x76,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x53, 0x69, 0x7a,
|
||||
0x65, 0x12, 0x41, 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f,
|
||||
0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f,
|
||||
0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x43, 0x68, 0x65, 0x63,
|
||||
0x6b, 0x73, 0x75, 0x6d, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x48, 0x61, 0x73, 0x68, 0x12, 0x2d, 0x0a, 0x10, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x02,
|
||||
0x18, 0x01, 0x52, 0x0f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x70,
|
||||
0x6f, 0x63, 0x68, 0x12, 0x32, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x04,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x52, 0x07,
|
||||
0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x42, 0x73, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x2e, 0x66,
|
||||
0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65,
|
||||
0x43, 0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73,
|
||||
0x2d, 0x61, 0x70, 0x69, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61,
|
||||
0x67, 0x65, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x73, 0x74, 0x6f,
|
||||
0x72, 0x61, 0x67, 0x65, 0x67, 0x72, 0x6f, 0x75, 0x70, 0xaa, 0x02, 0x20, 0x4e, 0x65, 0x6f, 0x2e,
|
||||
0x46, 0x69, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e,
|
||||
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_storagegroup_grpc_types_proto_rawDescOnce sync.Once
|
||||
file_storagegroup_grpc_types_proto_rawDescData = file_storagegroup_grpc_types_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_storagegroup_grpc_types_proto_rawDescGZIP() []byte {
|
||||
file_storagegroup_grpc_types_proto_rawDescOnce.Do(func() {
|
||||
file_storagegroup_grpc_types_proto_rawDescData = protoimpl.X.CompressGZIP(file_storagegroup_grpc_types_proto_rawDescData)
|
||||
})
|
||||
return file_storagegroup_grpc_types_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_storagegroup_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_storagegroup_grpc_types_proto_goTypes = []interface{}{
|
||||
(*StorageGroup)(nil), // 0: neo.fs.v2.storagegroup.StorageGroup
|
||||
(*grpc.Checksum)(nil), // 1: neo.fs.v2.refs.Checksum
|
||||
(*grpc.ObjectID)(nil), // 2: neo.fs.v2.refs.ObjectID
|
||||
}
|
||||
var file_storagegroup_grpc_types_proto_depIdxs = []int32{
|
||||
1, // 0: neo.fs.v2.storagegroup.StorageGroup.validation_hash:type_name -> neo.fs.v2.refs.Checksum
|
||||
2, // 1: neo.fs.v2.storagegroup.StorageGroup.members:type_name -> neo.fs.v2.refs.ObjectID
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_storagegroup_grpc_types_proto_init() }
|
||||
func file_storagegroup_grpc_types_proto_init() {
|
||||
if File_storagegroup_grpc_types_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_storagegroup_grpc_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*StorageGroup); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_storagegroup_grpc_types_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_storagegroup_grpc_types_proto_goTypes,
|
||||
DependencyIndexes: file_storagegroup_grpc_types_proto_depIdxs,
|
||||
MessageInfos: file_storagegroup_grpc_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_storagegroup_grpc_types_proto = out.File
|
||||
file_storagegroup_grpc_types_proto_rawDesc = nil
|
||||
file_storagegroup_grpc_types_proto_goTypes = nil
|
||||
file_storagegroup_grpc_types_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package storagegroup
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc"
|
||||
)
|
||||
|
||||
func (s *StorageGroup) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(s)
|
||||
}
|
||||
|
||||
func (s *StorageGroup) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(s, data, new(storagegroup.StorageGroup))
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package storagegroup
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
sizeField = 1
|
||||
hashField = 2
|
||||
expirationField = 3
|
||||
objectIDsField = 4
|
||||
)
|
||||
|
||||
// StableMarshal marshals unified storage group structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (s *StorageGroup) StableMarshal(buf []byte) []byte {
|
||||
if s == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, s.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += proto.UInt64Marshal(sizeField, buf[offset:], s.size)
|
||||
offset += proto.NestedStructureMarshal(hashField, buf[offset:], s.hash)
|
||||
offset += proto.UInt64Marshal(expirationField, buf[offset:], s.exp)
|
||||
refs.ObjectIDNestedListMarshal(objectIDsField, buf[offset:], s.members)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// StableSize of storage group structure marshalled by StableMarshal function.
|
||||
func (s *StorageGroup) StableSize() (size int) {
|
||||
if s == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += proto.UInt64Size(sizeField, s.size)
|
||||
size += proto.NestedStructureSize(hashField, s.hash)
|
||||
size += proto.UInt64Size(expirationField, s.exp)
|
||||
size += refs.ObjectIDNestedListSize(objectIDsField, s.members)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (s *StorageGroup) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(s, data, new(storagegroup.StorageGroup))
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package storagegroup_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message"
|
||||
messagetest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message/test"
|
||||
storagegrouptest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/test"
|
||||
)
|
||||
|
||||
func TestMessageConvert(t *testing.T) {
|
||||
messagetest.TestRPCMessage(t,
|
||||
func(empty bool) message.Message { return storagegrouptest.GenerateStorageGroup(empty) },
|
||||
)
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package storagegrouptest
|
||||
|
||||
import (
|
||||
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup"
|
||||
)
|
||||
|
||||
func GenerateStorageGroup(empty bool) *storagegroup.StorageGroup {
|
||||
m := new(storagegroup.StorageGroup)
|
||||
|
||||
if !empty {
|
||||
m.SetValidationDataSize(44)
|
||||
//nolint:staticcheck
|
||||
m.SetExpirationEpoch(55)
|
||||
m.SetMembers(refstest.GenerateObjectIDs(false))
|
||||
}
|
||||
|
||||
m.SetValidationHash(refstest.GenerateChecksum(empty))
|
||||
|
||||
return m
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package storagegroup
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
||||
)
|
||||
|
||||
// StorageGroup is a unified structure of StorageGroup
|
||||
// message from proto definition.
|
||||
type StorageGroup struct {
|
||||
size uint64
|
||||
|
||||
hash *refs.Checksum
|
||||
|
||||
exp uint64
|
||||
|
||||
members []refs.ObjectID
|
||||
}
|
||||
|
||||
// GetValidationDataSize of unified storage group structure.
|
||||
func (s *StorageGroup) GetValidationDataSize() uint64 {
|
||||
if s != nil {
|
||||
return s.size
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetValidationDataSize into unified storage group structure.
|
||||
func (s *StorageGroup) SetValidationDataSize(v uint64) {
|
||||
s.size = v
|
||||
}
|
||||
|
||||
// GetValidationHash of unified storage group structure.
|
||||
func (s *StorageGroup) GetValidationHash() *refs.Checksum {
|
||||
if s != nil {
|
||||
return s.hash
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetValidationHash into unified storage group structure.
|
||||
func (s *StorageGroup) SetValidationHash(v *refs.Checksum) {
|
||||
s.hash = v
|
||||
}
|
||||
|
||||
// GetExpirationEpoch of unified storage group structure.
|
||||
//
|
||||
// Deprecated: Do not use.
|
||||
func (s *StorageGroup) GetExpirationEpoch() uint64 {
|
||||
if s != nil {
|
||||
return s.exp
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetExpirationEpoch into unified storage group structure.
|
||||
//
|
||||
// Deprecated: Do not use.
|
||||
func (s *StorageGroup) SetExpirationEpoch(v uint64) {
|
||||
s.exp = v
|
||||
}
|
||||
|
||||
// GetMembers of unified storage group structure. Members are objects of
|
||||
// storage group.
|
||||
func (s *StorageGroup) GetMembers() []refs.ObjectID {
|
||||
if s != nil {
|
||||
return s.members
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetMembers into unified storage group structure. Members are objects of
|
||||
// storage group.
|
||||
func (s *StorageGroup) SetMembers(v []refs.ObjectID) {
|
||||
s.members = v
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: tombstone/grpc/types.proto
|
||||
|
||||
package tombstone
|
||||
|
|
|
@ -10,8 +10,7 @@ import (
|
|||
"encoding/binary"
|
||||
"math"
|
||||
"math/bits"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -22,22 +21,14 @@ type (
|
|||
)
|
||||
|
||||
func BytesMarshal(field int, buf, v []byte) int {
|
||||
return bytesMarshal(field, buf, v)
|
||||
}
|
||||
|
||||
func BytesSize(field int, v []byte) int {
|
||||
return bytesSize(field, v)
|
||||
}
|
||||
|
||||
func bytesMarshal[T ~[]byte | ~string](field int, buf []byte, v T) int {
|
||||
if len(v) == 0 {
|
||||
return 0
|
||||
}
|
||||
return bytesMarshalNoCheck(field, buf, v)
|
||||
return bytesMarshal(field, buf, v)
|
||||
}
|
||||
|
||||
func bytesMarshalNoCheck[T ~[]byte | ~string](field int, buf []byte, v T) int {
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
||||
func bytesMarshal(field int, buf, v []byte) int {
|
||||
prefix := field<<3 | 0x2
|
||||
|
||||
// buf length check can prevent panic at PutUvarint, but it will make
|
||||
// marshaller a bit slower.
|
||||
|
@ -48,23 +39,26 @@ func bytesMarshalNoCheck[T ~[]byte | ~string](field int, buf []byte, v T) int {
|
|||
return i
|
||||
}
|
||||
|
||||
func bytesSize[T ~[]byte | ~string](field int, v T) int {
|
||||
if len(v) == 0 {
|
||||
func BytesSize(field int, v []byte) int {
|
||||
ln := len(v)
|
||||
if ln == 0 {
|
||||
return 0
|
||||
}
|
||||
return bytesSizeNoCheck(field, v)
|
||||
return bytesSize(field, v)
|
||||
}
|
||||
|
||||
func bytesSizeNoCheck[T ~[]byte | ~string](field int, v T) int {
|
||||
return protowire.SizeGroup(protowire.Number(field), protowire.SizeBytes(len(v)))
|
||||
func bytesSize(field int, v []byte) int {
|
||||
prefix := field<<3 | 0x2
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + VarUIntSize(uint64(len(v))) + len(v)
|
||||
}
|
||||
|
||||
func StringMarshal(field int, buf []byte, v string) int {
|
||||
return bytesMarshal(field, buf, v)
|
||||
return BytesMarshal(field, buf, []byte(v))
|
||||
}
|
||||
|
||||
func StringSize(field int, v string) int {
|
||||
return bytesSize(field, v)
|
||||
return BytesSize(field, []byte(v))
|
||||
}
|
||||
|
||||
func BoolMarshal(field int, buf []byte, v bool) int {
|
||||
|
@ -72,13 +66,12 @@ func BoolMarshal(field int, buf []byte, v bool) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.VarintType)
|
||||
prefix := field << 3
|
||||
|
||||
// buf length check can prevent panic at PutUvarint, but it will make
|
||||
// marshaller a bit slower.
|
||||
i := binary.PutUvarint(buf, uint64(prefix))
|
||||
const boolTrueValue = 0x1
|
||||
buf[i] = boolTrueValue
|
||||
buf[i] = 0x1
|
||||
|
||||
return i + 1
|
||||
}
|
||||
|
@ -87,8 +80,10 @@ func BoolSize(field int, v bool) int {
|
|||
if !v {
|
||||
return 0
|
||||
}
|
||||
const boolLength = 1
|
||||
return protowire.SizeGroup(protowire.Number(field), boolLength)
|
||||
|
||||
prefix := field << 3
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + 1 // bool is always 1 byte long
|
||||
}
|
||||
|
||||
func UInt64Marshal(field int, buf []byte, v uint64) int {
|
||||
|
@ -96,7 +91,7 @@ func UInt64Marshal(field int, buf []byte, v uint64) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.VarintType)
|
||||
prefix := field << 3
|
||||
|
||||
// buf length check can prevent panic at PutUvarint, but it will make
|
||||
// marshaller a bit slower.
|
||||
|
@ -110,7 +105,10 @@ func UInt64Size(field int, v uint64) int {
|
|||
if v == 0 {
|
||||
return 0
|
||||
}
|
||||
return protowire.SizeGroup(protowire.Number(field), protowire.SizeVarint(v))
|
||||
|
||||
prefix := field << 3
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + VarUIntSize(v)
|
||||
}
|
||||
|
||||
func Int64Marshal(field int, buf []byte, v int64) int {
|
||||
|
@ -149,7 +147,7 @@ func RepeatedBytesMarshal(field int, buf []byte, v [][]byte) int {
|
|||
var offset int
|
||||
|
||||
for i := range v {
|
||||
offset += bytesMarshalNoCheck(field, buf[offset:], v[i])
|
||||
offset += bytesMarshal(field, buf[offset:], v[i])
|
||||
}
|
||||
|
||||
return offset
|
||||
|
@ -157,7 +155,7 @@ func RepeatedBytesMarshal(field int, buf []byte, v [][]byte) int {
|
|||
|
||||
func RepeatedBytesSize(field int, v [][]byte) (size int) {
|
||||
for i := range v {
|
||||
size += bytesSizeNoCheck(field, v[i])
|
||||
size += bytesSize(field, v[i])
|
||||
}
|
||||
|
||||
return size
|
||||
|
@ -167,7 +165,7 @@ func RepeatedStringMarshal(field int, buf []byte, v []string) int {
|
|||
var offset int
|
||||
|
||||
for i := range v {
|
||||
offset += bytesMarshalNoCheck(field, buf[offset:], v[i])
|
||||
offset += bytesMarshal(field, buf[offset:], []byte(v[i]))
|
||||
}
|
||||
|
||||
return offset
|
||||
|
@ -175,73 +173,123 @@ func RepeatedStringMarshal(field int, buf []byte, v []string) int {
|
|||
|
||||
func RepeatedStringSize(field int, v []string) (size int) {
|
||||
for i := range v {
|
||||
size += bytesSizeNoCheck(field, v[i])
|
||||
size += bytesSize(field, []byte(v[i]))
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func repeatedUIntSize[T ~uint64 | ~int64 | ~uint32 | ~int32](field int, v []T) (size, arraySize int) {
|
||||
if len(v) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
for i := range v {
|
||||
arraySize += protowire.SizeVarint(uint64(v[i]))
|
||||
}
|
||||
|
||||
size = protowire.SizeGroup(protowire.Number(field), protowire.SizeBytes(arraySize))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func repeatedUIntMarshal[T ~uint64 | ~int64 | ~uint32 | ~int32](field int, buf []byte, v []T) int {
|
||||
func RepeatedUInt64Marshal(field int, buf []byte, v []uint64) int {
|
||||
if len(v) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
||||
prefix := field<<3 | 0x02
|
||||
offset := binary.PutUvarint(buf, uint64(prefix))
|
||||
|
||||
_, arrSize := repeatedUIntSize(field, v)
|
||||
_, arrSize := RepeatedUInt64Size(field, v)
|
||||
offset += binary.PutUvarint(buf[offset:], uint64(arrSize))
|
||||
for i := range v {
|
||||
offset += binary.PutUvarint(buf[offset:], uint64(v[i]))
|
||||
offset += binary.PutUvarint(buf[offset:], v[i])
|
||||
}
|
||||
|
||||
return offset
|
||||
}
|
||||
|
||||
func RepeatedUInt64Marshal(field int, buf []byte, v []uint64) int {
|
||||
return repeatedUIntMarshal(field, buf, v)
|
||||
}
|
||||
|
||||
func RepeatedUInt64Size(field int, v []uint64) (size, arraySize int) {
|
||||
return repeatedUIntSize(field, v)
|
||||
if len(v) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
for i := range v {
|
||||
size += VarUIntSize(v[i])
|
||||
}
|
||||
arraySize = size
|
||||
|
||||
size += VarUIntSize(uint64(size))
|
||||
|
||||
prefix := field<<3 | 0x2
|
||||
size += VarUIntSize(uint64(prefix))
|
||||
|
||||
return size, arraySize
|
||||
}
|
||||
|
||||
func RepeatedInt64Marshal(field int, buf []byte, v []int64) int {
|
||||
return repeatedUIntMarshal(field, buf, v)
|
||||
if len(v) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Marshal(field, buf, convert)
|
||||
}
|
||||
|
||||
func RepeatedInt64Size(field int, v []int64) (size, arraySize int) {
|
||||
return repeatedUIntSize(field, v)
|
||||
if len(v) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Size(field, convert)
|
||||
}
|
||||
|
||||
func RepeatedUInt32Marshal(field int, buf []byte, v []uint32) int {
|
||||
return repeatedUIntMarshal(field, buf, v)
|
||||
if len(v) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Marshal(field, buf, convert)
|
||||
}
|
||||
|
||||
func RepeatedUInt32Size(field int, v []uint32) (size, arraySize int) {
|
||||
return repeatedUIntSize(field, v)
|
||||
if len(v) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Size(field, convert)
|
||||
}
|
||||
|
||||
func RepeatedInt32Marshal(field int, buf []byte, v []int32) int {
|
||||
return repeatedUIntMarshal(field, buf, v)
|
||||
if len(v) == 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Marshal(field, buf, convert)
|
||||
}
|
||||
|
||||
func RepeatedInt32Size(field int, v []int32) (size, arraySize int) {
|
||||
return repeatedUIntSize(field, v)
|
||||
if len(v) == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
convert := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
convert[i] = uint64(v[i])
|
||||
}
|
||||
|
||||
return RepeatedUInt64Size(field, convert)
|
||||
}
|
||||
|
||||
// VarUIntSize returns length of varint byte sequence for uint64 value 'x'.
|
||||
|
@ -249,27 +297,36 @@ func VarUIntSize(x uint64) int {
|
|||
return (bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
|
||||
func NestedStructureMarshal[T stableMarshaller](field int64, buf []byte, v T) int {
|
||||
n := v.StableSize()
|
||||
if n == 0 {
|
||||
func NestedStructurePrefix(field int64) (prefix uint64, ln int) {
|
||||
prefix = uint64(field<<3 | 0x02)
|
||||
return prefix, VarUIntSize(prefix)
|
||||
}
|
||||
|
||||
func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) int {
|
||||
if v == nil || reflect.ValueOf(v).IsNil() {
|
||||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.BytesType)
|
||||
prefix, _ := NestedStructurePrefix(field)
|
||||
offset := binary.PutUvarint(buf, prefix)
|
||||
|
||||
n := v.StableSize()
|
||||
offset += binary.PutUvarint(buf[offset:], uint64(n))
|
||||
v.StableMarshal(buf[offset:])
|
||||
|
||||
return offset + n
|
||||
}
|
||||
|
||||
func NestedStructureSize[T stableMarshaller](field int64, v T) (size int) {
|
||||
n := v.StableSize()
|
||||
if n == 0 {
|
||||
func NestedStructureSize(field int64, v stableMarshaller) (size int) {
|
||||
if v == nil || reflect.ValueOf(v).IsNil() {
|
||||
return 0
|
||||
}
|
||||
size = protowire.SizeGroup(protowire.Number(field), protowire.SizeBytes(n))
|
||||
return
|
||||
|
||||
_, ln := NestedStructurePrefix(field)
|
||||
n := v.StableSize()
|
||||
size = ln + VarUIntSize(uint64(n)) + n
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func Fixed64Marshal(field int, buf []byte, v uint64) int {
|
||||
|
@ -277,7 +334,7 @@ func Fixed64Marshal(field int, buf []byte, v uint64) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.Fixed64Type)
|
||||
prefix := field<<3 | 1
|
||||
|
||||
// buf length check can prevent panic at PutUvarint, but it will make
|
||||
// marshaller a bit slower.
|
||||
|
@ -291,7 +348,10 @@ func Fixed64Size(fNum int, v uint64) int {
|
|||
if v == 0 {
|
||||
return 0
|
||||
}
|
||||
return protowire.SizeGroup(protowire.Number(fNum), protowire.SizeFixed64())
|
||||
|
||||
prefix := fNum<<3 | 1
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + 8
|
||||
}
|
||||
|
||||
func Float64Marshal(field int, buf []byte, v float64) int {
|
||||
|
@ -299,7 +359,7 @@ func Float64Marshal(field int, buf []byte, v float64) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.Fixed64Type)
|
||||
prefix := field<<3 | 1
|
||||
|
||||
i := binary.PutUvarint(buf, uint64(prefix))
|
||||
binary.LittleEndian.PutUint64(buf[i:], math.Float64bits(v))
|
||||
|
@ -311,7 +371,10 @@ func Float64Size(fNum int, v float64) int {
|
|||
if v == 0 {
|
||||
return 0
|
||||
}
|
||||
return protowire.SizeGroup(protowire.Number(fNum), protowire.SizeFixed64())
|
||||
|
||||
prefix := fNum<<3 | 1
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + 8
|
||||
}
|
||||
|
||||
// Fixed32Marshal encodes uint32 value to Protocol Buffers fixed32 field with specified number,
|
||||
|
@ -323,7 +386,7 @@ func Fixed32Marshal(field int, buf []byte, v uint32) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
prefix := protowire.EncodeTag(protowire.Number(field), protowire.Fixed32Type)
|
||||
prefix := field<<3 | 5
|
||||
|
||||
// buf length check can prevent panic at PutUvarint, but it will make
|
||||
// marshaller a bit slower.
|
||||
|
@ -339,5 +402,8 @@ func Fixed32Size(fNum int, v uint32) int {
|
|||
if v == 0 {
|
||||
return 0
|
||||
}
|
||||
return protowire.SizeGroup(protowire.Number(fNum), protowire.SizeFixed32())
|
||||
|
||||
prefix := fNum<<3 | 5
|
||||
|
||||
return VarUIntSize(uint64(prefix)) + 4
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.30.0
|
||||
// protoc v4.23.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.9
|
||||
// source: util/proto/test/test.proto
|
||||
|
||||
package test
|
||||
|
|
|
@ -59,7 +59,6 @@ func emitMessage(g *protogen.GeneratedFile, msg *protogen.Message) {
|
|||
g.P("//")
|
||||
g.P("// Structures with the same field values have the same binary size.")
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") StableSize() (size int) {")
|
||||
g.P("if x == nil { return 0 }")
|
||||
if len(fs) != 0 {
|
||||
for _, f := range fs {
|
||||
if f.Desc.IsList() && marshalers[f.Desc.Kind()].RepeatedDouble {
|
||||
|
|
Loading…
Reference in New Issue