Move api-v2 files into v2 subdir
This subdir contains generated proto files and small wrappers.
This commit is contained in:
parent
0ee1c3653d
commit
1f143e54bd
48 changed files with 1479 additions and 1515 deletions
|
@ -1,362 +0,0 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"math/bits"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (m *PlacementRule) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, m.StableSize())
|
||||
}
|
||||
|
||||
var (
|
||||
i, n, offset int
|
||||
)
|
||||
|
||||
// Write replication factor field.
|
||||
|
||||
buf[i] = 0x08 // id:0x1 << 3 | wiretype:0x0
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(m.ReplFactor))
|
||||
i += 1 + offset
|
||||
|
||||
// write select/filter groups field
|
||||
for j := range m.SfGroups {
|
||||
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
|
||||
|
||||
n, _ = m.SfGroups[j].stableSizeWithExclude()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
|
||||
_, err := m.SfGroups[j].StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "can't marshal SFGroup id:%d", j)
|
||||
}
|
||||
|
||||
i += 1 + offset + n
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule) StableSize() int {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
_ = ln
|
||||
|
||||
// size of replication factor field
|
||||
size += 1 + uvarIntSize(uint64(m.ReplFactor)) // wiretype + varint
|
||||
|
||||
for i := range m.SfGroups {
|
||||
ln, _ = m.SfGroups[i].stableSizeWithExclude()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + size of struct + struct
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
size, excludeSize := m.stableSizeWithExclude()
|
||||
if buf == nil {
|
||||
buf = make([]byte, size)
|
||||
}
|
||||
|
||||
var (
|
||||
i, n, offset int
|
||||
)
|
||||
|
||||
// write filters field
|
||||
for j := range m.Filters {
|
||||
buf[i] = 0x0A // id:0x1 << 3 | wiretype:0x2
|
||||
n = m.Filters[j].stableSize()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
_, err := m.Filters[j].StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "can't marshal Filter id:%d", j)
|
||||
}
|
||||
i += 1 + offset + n
|
||||
}
|
||||
|
||||
// write selectors field
|
||||
for j := range m.Selectors {
|
||||
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
|
||||
n = m.Selectors[j].stableSize()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
_, err := m.Selectors[j].StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "can't marshal Selector id:%d", j)
|
||||
}
|
||||
i += 1 + offset + n
|
||||
}
|
||||
|
||||
// write excluded field in packed format
|
||||
buf[i] = 0x1A // id:0x3 << 3 | wiretype:0x2
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(excludeSize))
|
||||
i += 1 + offset
|
||||
for j := range m.Exclude {
|
||||
offset = binary.PutUvarint(buf[i:], uint64(m.Exclude[j]))
|
||||
i += offset
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup) stableSizeWithExclude() (int, int) {
|
||||
if m == nil {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
|
||||
// size of filters field
|
||||
for i := range m.Filters {
|
||||
ln = m.Filters[i].stableSize()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + size of struct + struct
|
||||
}
|
||||
|
||||
// size of selectors field
|
||||
for i := range m.Selectors {
|
||||
ln = m.Selectors[i].stableSize()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + size of struct + struct
|
||||
}
|
||||
|
||||
// size of exclude field
|
||||
ln = 0
|
||||
for i := range m.Exclude {
|
||||
ln += uvarIntSize(uint64(m.Exclude[i]))
|
||||
}
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + packed varints size + packed varints
|
||||
|
||||
return size, ln
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Selector) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, m.stableSize())
|
||||
}
|
||||
|
||||
var (
|
||||
i, offset int
|
||||
)
|
||||
|
||||
// write count field
|
||||
buf[i] = 0x8 // id:0x1 << 3 | wiretype:0x0
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(m.Count))
|
||||
i += 1 + offset
|
||||
|
||||
// write key field
|
||||
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(len(m.Key)))
|
||||
copy(buf[i+1+offset:], m.Key)
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Selector) stableSize() int {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
|
||||
// size of count field
|
||||
size += 1 + uvarIntSize(uint64(m.Count))
|
||||
|
||||
// size of key field
|
||||
ln = len(m.Key)
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, m.stableSize())
|
||||
}
|
||||
|
||||
var (
|
||||
i, n, offset int
|
||||
)
|
||||
|
||||
// write key field
|
||||
buf[i] = 0x0A // id:0x1 << 3 | wiretype:0x2
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(len(m.Key)))
|
||||
n = copy(buf[i+1+offset:], m.Key)
|
||||
i += 1 + offset + n
|
||||
|
||||
// write simple filter field
|
||||
if m.F != nil {
|
||||
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
|
||||
n = m.F.stableSize()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
_, err := m.F.StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't marshal netmap filter")
|
||||
}
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter) stableSize() int {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
|
||||
// size of key field
|
||||
ln = len(m.Key)
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
|
||||
// size of simple filter
|
||||
if m.F != nil {
|
||||
ln = m.F.stableSize()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, m.stableSize())
|
||||
}
|
||||
|
||||
var (
|
||||
i, n, offset int
|
||||
)
|
||||
|
||||
// write key field
|
||||
buf[i] = 0x08 // id:0x1 << 3 | wiretype:0x0
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(m.Op))
|
||||
i += 1 + offset
|
||||
|
||||
// write value if present
|
||||
if val, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_Value); ok {
|
||||
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(len(val.Value)))
|
||||
copy(buf[i+1+offset:], val.Value)
|
||||
} else if filters, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_FArgs); ok {
|
||||
if filters.FArgs != nil {
|
||||
buf[i] = 0x1A // id:0x3 << 3 | wiretype:0x2
|
||||
n = filters.FArgs.stableSize()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
_, err := filters.FArgs.StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can't marshal simple filters")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) stableSize() int {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
|
||||
// size of key field
|
||||
size += 1 + uvarIntSize(uint64(m.Op))
|
||||
|
||||
if val, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_Value); ok {
|
||||
// size of value if present
|
||||
ln = len(val.Value)
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
} else if filters, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_FArgs); ok {
|
||||
// size of simple filters if present
|
||||
if filters.FArgs != nil {
|
||||
ln = filters.FArgs.stableSize()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
}
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) StableMarshal(buf []byte) ([]byte, error) {
|
||||
if m == nil {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, m.stableSize())
|
||||
}
|
||||
|
||||
var (
|
||||
i, n, offset int
|
||||
)
|
||||
|
||||
// write filters field
|
||||
for j := range m.Filters {
|
||||
buf[i] = 0x0A // id:0x1 << 3 | wiretype:0x2
|
||||
n = m.Filters[j].stableSize()
|
||||
offset = binary.PutUvarint(buf[i+1:], uint64(n))
|
||||
_, err := m.Filters[j].StableMarshal(buf[i+1+offset:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "can't marshal simple filter id:%d", j)
|
||||
}
|
||||
i += 1 + offset + n
|
||||
}
|
||||
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) stableSize() int {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var (
|
||||
ln, size int
|
||||
)
|
||||
|
||||
// size of key field
|
||||
for i := range m.Filters {
|
||||
ln = m.Filters[i].stableSize()
|
||||
size += 1 + uvarIntSize(uint64(ln)) + ln
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
// uvarIntSize returns length of varint byte sequence for uint64 value 'x'.
|
||||
func uvarIntSize(x uint64) int {
|
||||
return (bits.Len64(x|1) + 6) / 7
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
package v2
|
||||
|
||||
// SetOp sets operation of the simple filter.
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) SetOp(v PlacementRule_SFGroup_Filter_SimpleFilter_Operation) {
|
||||
if m != nil {
|
||||
m.Op = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetValue sets value of the simple filter.
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) SetValue(v string) {
|
||||
if m != nil {
|
||||
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_Value{
|
||||
Value: v,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetFArgs sets filter args of the simple filter.
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) SetFArgs(v *PlacementRule_SFGroup_Filter_SimpleFilters) {
|
||||
if m != nil {
|
||||
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_FArgs{
|
||||
FArgs: v,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetFilters sets list of the simple filters.
|
||||
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) SetFilters(v []*PlacementRule_SFGroup_Filter_SimpleFilter) {
|
||||
if m != nil {
|
||||
m.Filters = v
|
||||
}
|
||||
}
|
||||
|
||||
// SeyKey sets key of the filter.
|
||||
func (m *PlacementRule_SFGroup_Filter) SeyKey(v string) {
|
||||
if m != nil {
|
||||
m.Key = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetF sets simple filter of the filter.
|
||||
func (m *PlacementRule_SFGroup_Filter) SetF(v *PlacementRule_SFGroup_Filter_SimpleFilter) {
|
||||
if m != nil {
|
||||
m.F = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetCount sets count value of the selector.
|
||||
func (m *PlacementRule_SFGroup_Selector) SetCount(v uint32) {
|
||||
if m != nil {
|
||||
m.Count = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetKey sets key of the selector.
|
||||
func (m *PlacementRule_SFGroup_Selector) SetKey(v string) {
|
||||
if m != nil {
|
||||
m.Key = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetFilters sets list of the filters.
|
||||
func (m *PlacementRule_SFGroup) SetFilters(v []*PlacementRule_SFGroup_Filter) {
|
||||
if m != nil {
|
||||
m.Filters = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetSelectors sets list of the selectors.
|
||||
func (m *PlacementRule_SFGroup) SetSelectors(v []*PlacementRule_SFGroup_Selector) {
|
||||
if m != nil {
|
||||
m.Selectors = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetExclude sets exclude list.
|
||||
func (m *PlacementRule_SFGroup) SetExclude(v []uint32) {
|
||||
if m != nil {
|
||||
m.Exclude = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetReplFactor sets replication factor of the placement rule.
|
||||
func (m *PlacementRule) SetReplFactor(v uint32) {
|
||||
if m != nil {
|
||||
m.ReplFactor = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetSfGroups sets list of the selector-filter groups.
|
||||
func (m *PlacementRule) SetSfGroups(v []*PlacementRule_SFGroup) {
|
||||
if m != nil {
|
||||
m.SfGroups = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetKey sets key to the node attribute.
|
||||
func (m *NodeInfo_Attribute) SetKey(v string) {
|
||||
if m != nil {
|
||||
m.Key = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetValue sets value of the node attribute.
|
||||
func (m *NodeInfo_Attribute) SetValue(v string) {
|
||||
if m != nil {
|
||||
m.Value = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetAddress sets node network address.
|
||||
func (m *NodeInfo) SetAddress(v string) {
|
||||
if m != nil {
|
||||
m.Address = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetPublicKey sets node public key in a binary format.
|
||||
func (m *NodeInfo) SetPublicKey(v []byte) {
|
||||
if m != nil {
|
||||
m.PublicKey = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetAttributes sets list of the node attributes.
|
||||
func (m *NodeInfo) SetAttributes(v []*NodeInfo_Attribute) {
|
||||
if m != nil {
|
||||
m.Attributes = v
|
||||
}
|
||||
}
|
||||
|
||||
// SetState sets node state.
|
||||
func (m *NodeInfo) SetState(v NodeInfo_State) {
|
||||
if m != nil {
|
||||
m.State = v
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,92 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package netmap.v2;
|
||||
|
||||
option go_package = "github.com/nspcc-dev/neofs-api-go/netmap/v2";
|
||||
option csharp_namespace = "NeoFS.API.Netmap";
|
||||
|
||||
message PlacementRule {
|
||||
uint32 repl_factor = 1;
|
||||
|
||||
message SFGroup {
|
||||
message Filter {
|
||||
string key = 1;
|
||||
|
||||
message SimpleFilters {
|
||||
repeated SimpleFilter filters = 1;
|
||||
}
|
||||
|
||||
message SimpleFilter {
|
||||
enum Operation {
|
||||
NP = 0;
|
||||
EQ = 1;
|
||||
NE = 2;
|
||||
GT = 3;
|
||||
GE = 4;
|
||||
LT = 5;
|
||||
LE = 6;
|
||||
OR = 7;
|
||||
AND = 8;
|
||||
}
|
||||
|
||||
Operation op = 1;
|
||||
|
||||
oneof args {
|
||||
string value = 2;
|
||||
SimpleFilters f_args = 3;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleFilter f = 2;
|
||||
}
|
||||
|
||||
repeated Filter filters = 1;
|
||||
|
||||
message Selector {
|
||||
uint32 count = 1;
|
||||
string key = 2;
|
||||
}
|
||||
|
||||
repeated Selector selectors = 2;
|
||||
|
||||
repeated uint32 exclude = 3;
|
||||
}
|
||||
|
||||
repeated SFGroup sf_groups = 2;
|
||||
}
|
||||
|
||||
// Groups the information about the NeoFS node.
|
||||
message NodeInfo {
|
||||
// Carries network address of the NeoFS node.
|
||||
string address = 1;
|
||||
|
||||
// Carries public key of the NeoFS node in a binary format.
|
||||
bytes public_key = 2;
|
||||
|
||||
// Groups attributes of the NeoFS node.
|
||||
message Attribute {
|
||||
// Carries string key to the node attribute.
|
||||
string key = 1;
|
||||
|
||||
// Carries string value of the node attribute.
|
||||
string value = 2;
|
||||
}
|
||||
|
||||
// Carries list of the NeoFS node attributes in a string key-value format.
|
||||
repeated Attribute attributes = 3;
|
||||
|
||||
// Represents the enumeration of various states of the NeoFS node.
|
||||
enum State {
|
||||
// Undefined state.
|
||||
UNKNOWN = 0;
|
||||
|
||||
// Active state in the network.
|
||||
ONLINE = 1;
|
||||
|
||||
// Network unavailable state.
|
||||
OFFLINE = 2;
|
||||
}
|
||||
|
||||
// Carries state of the NeoFS node.
|
||||
State state = 4;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue