Update field names in setters and tests

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-08-14 10:22:15 +03:00 committed by Stanislav Bogatyrev
parent 8aca8c5787
commit 59858805a8
7 changed files with 57 additions and 64 deletions

View file

@ -68,12 +68,12 @@ func (m *Container) StableMarshal(buf []byte) ([]byte, error) {
// Write placement rule field.
if m.Rules != nil {
if m.PlacementPolicy != nil {
buf[i] = 0x2A // id:0x5 << 3 | wiretype:0x2
n = m.Rules.StableSize()
n = m.PlacementPolicy.StableSize()
offset = binary.PutUvarint(buf[i+1:], uint64(n))
_, err := m.Rules.StableMarshal(buf[i+1+offset:])
_, err := m.PlacementPolicy.StableMarshal(buf[i+1+offset:])
if err != nil {
return nil, errors.Wrapf(err, "can't marshal attribute %v",
m.Attributes[i].Key)
@ -110,8 +110,8 @@ func (m *Container) StableSize() int {
}
// size of placement rule
if m.Rules != nil {
ln = m.Rules.StableSize()
if m.PlacementPolicy != nil {
ln = m.PlacementPolicy.StableSize()
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + size of struct + struct
}

View file

@ -23,17 +23,17 @@ var (
Value: "Mir",
},
},
Rules: &netmap.PlacementRule{
PlacementPolicy: &netmap.PlacementPolicy{
ReplFactor: 4,
SfGroups: []*netmap.PlacementRule_SFGroup{
FilterGroups: []*netmap.PlacementPolicy_FilterGroup{
{
Selectors: []*netmap.PlacementRule_SFGroup_Selector{
Selectors: []*netmap.PlacementPolicy_FilterGroup_Selector{
{
Count: 1,
Key: "Node",
},
},
Filters: []*netmap.PlacementRule_SFGroup_Filter{
Filters: []*netmap.PlacementPolicy_FilterGroup_Filter{
{
Key: "City",
},

View file

@ -48,8 +48,8 @@ func (m *Container) SetAttributes(v []*Container_Attribute) {
}
// SetRules sets placement rules of the container.
func (m *Container) SetRules(v *netmap.PlacementRule) {
func (m *Container) SetRules(v *netmap.PlacementPolicy) {
if m != nil {
m.Rules = v
m.PlacementPolicy = v
}
}

View file

@ -7,7 +7,7 @@ import (
"github.com/pkg/errors"
)
func (m *PlacementRule) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -27,13 +27,13 @@ func (m *PlacementRule) StableMarshal(buf []byte) ([]byte, error) {
i += 1 + offset
// write select/filter groups field
for j := range m.SfGroups {
for j := range m.FilterGroups {
buf[i] = 0x12 // id:0x2 << 3 | wiretype:0x2
n, _ = m.SfGroups[j].stableSizeWithExclude()
n, _ = m.FilterGroups[j].stableSizeWithExclude()
offset = binary.PutUvarint(buf[i+1:], uint64(n))
_, err := m.SfGroups[j].StableMarshal(buf[i+1+offset:])
_, err := m.FilterGroups[j].StableMarshal(buf[i+1+offset:])
if err != nil {
return nil, errors.Wrapf(err, "can't marshal SFGroup id:%d", j)
}
@ -44,7 +44,7 @@ func (m *PlacementRule) StableMarshal(buf []byte) ([]byte, error) {
return buf, nil
}
func (m *PlacementRule) StableSize() int {
func (m *PlacementPolicy) StableSize() int {
if m == nil {
return 0
}
@ -57,15 +57,15 @@ func (m *PlacementRule) StableSize() int {
// size of replication factor field
size += 1 + uvarIntSize(uint64(m.ReplFactor)) // wiretype + varint
for i := range m.SfGroups {
ln, _ = m.SfGroups[i].stableSizeWithExclude()
for i := range m.FilterGroups {
ln, _ = m.FilterGroups[i].stableSizeWithExclude()
size += 1 + uvarIntSize(uint64(ln)) + ln // wiretype + size of struct + struct
}
return size
}
func (m *PlacementRule_SFGroup) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy_FilterGroup) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -115,7 +115,7 @@ func (m *PlacementRule_SFGroup) StableMarshal(buf []byte) ([]byte, error) {
return buf, nil
}
func (m *PlacementRule_SFGroup) stableSizeWithExclude() (int, int) {
func (m *PlacementPolicy_FilterGroup) stableSizeWithExclude() (int, int) {
if m == nil {
return 0, 0
}
@ -146,7 +146,7 @@ func (m *PlacementRule_SFGroup) stableSizeWithExclude() (int, int) {
return size, ln
}
func (m *PlacementRule_SFGroup_Selector) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy_FilterGroup_Selector) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -172,7 +172,7 @@ func (m *PlacementRule_SFGroup_Selector) StableMarshal(buf []byte) ([]byte, erro
return buf, nil
}
func (m *PlacementRule_SFGroup_Selector) stableSize() int {
func (m *PlacementPolicy_FilterGroup_Selector) stableSize() int {
if m == nil {
return 0
}
@ -191,7 +191,7 @@ func (m *PlacementRule_SFGroup_Selector) stableSize() int {
return size
}
func (m *PlacementRule_SFGroup_Filter) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy_FilterGroup_Filter) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -224,7 +224,7 @@ func (m *PlacementRule_SFGroup_Filter) StableMarshal(buf []byte) ([]byte, error)
return buf, nil
}
func (m *PlacementRule_SFGroup_Filter) stableSize() int {
func (m *PlacementPolicy_FilterGroup_Filter) stableSize() int {
if m == nil {
return 0
}
@ -246,7 +246,7 @@ func (m *PlacementRule_SFGroup_Filter) stableSize() int {
return size
}
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -265,11 +265,11 @@ func (m *PlacementRule_SFGroup_Filter_SimpleFilter) StableMarshal(buf []byte) ([
i += 1 + offset
// write value if present
if val, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_Value); ok {
if val, ok := m.Args.(*PlacementPolicy_FilterGroup_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 {
} else if filters, ok := m.Args.(*PlacementPolicy_FilterGroup_Filter_SimpleFilter_FArgs); ok {
if filters.FArgs != nil {
buf[i] = 0x1A // id:0x3 << 3 | wiretype:0x2
n = filters.FArgs.stableSize()
@ -284,7 +284,7 @@ func (m *PlacementRule_SFGroup_Filter_SimpleFilter) StableMarshal(buf []byte) ([
return buf, nil
}
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) stableSize() int {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter) stableSize() int {
if m == nil {
return 0
}
@ -296,11 +296,11 @@ func (m *PlacementRule_SFGroup_Filter_SimpleFilter) stableSize() int {
// size of key field
size += 1 + uvarIntSize(uint64(m.Op))
if val, ok := m.Args.(*PlacementRule_SFGroup_Filter_SimpleFilter_Value); ok {
if val, ok := m.Args.(*PlacementPolicy_FilterGroup_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 {
} else if filters, ok := m.Args.(*PlacementPolicy_FilterGroup_Filter_SimpleFilter_FArgs); ok {
// size of simple filters if present
if filters.FArgs != nil {
ln = filters.FArgs.stableSize()
@ -311,7 +311,7 @@ func (m *PlacementRule_SFGroup_Filter_SimpleFilter) stableSize() int {
return size
}
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) StableMarshal(buf []byte) ([]byte, error) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter_SimpleFilters) StableMarshal(buf []byte) ([]byte, error) {
if m == nil {
return []byte{}, nil
}
@ -339,7 +339,7 @@ func (m *PlacementRule_SFGroup_Filter_SimpleFilters) StableMarshal(buf []byte) (
return buf, nil
}
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) stableSize() int {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter_SimpleFilters) stableSize() int {
if m == nil {
return 0
}

View file

@ -1,97 +1,97 @@
package netmap
// SetOp sets operation of the simple filter.
func (m *PlacementRule_SFGroup_Filter_SimpleFilter) SetOp(v PlacementRule_SFGroup_Filter_SimpleFilter_Operation) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter) SetOp(v PlacementPolicy_FilterGroup_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) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter) SetValue(v string) {
if m != nil {
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_Value{
m.Args = &PlacementPolicy_FilterGroup_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) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter) SetFArgs(v *PlacementPolicy_FilterGroup_Filter_SimpleFilter_SimpleFilters) {
if m != nil {
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_FArgs{
m.Args = &PlacementPolicy_FilterGroup_Filter_SimpleFilter_FArgs{
FArgs: v,
}
}
}
// SetFilters sets list of the simple filters.
func (m *PlacementRule_SFGroup_Filter_SimpleFilters) SetFilters(v []*PlacementRule_SFGroup_Filter_SimpleFilter) {
func (m *PlacementPolicy_FilterGroup_Filter_SimpleFilter_SimpleFilters) SetFilters(v []*PlacementPolicy_FilterGroup_Filter_SimpleFilter) {
if m != nil {
m.Filters = v
}
}
// SeyKey sets key of the filter.
func (m *PlacementRule_SFGroup_Filter) SeyKey(v string) {
func (m *PlacementPolicy_FilterGroup_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) {
func (m *PlacementPolicy_FilterGroup_Filter) SetF(v *PlacementPolicy_FilterGroup_Filter_SimpleFilter) {
if m != nil {
m.F = v
}
}
// SetCount sets count value of the selector.
func (m *PlacementRule_SFGroup_Selector) SetCount(v uint32) {
func (m *PlacementPolicy_FilterGroup_Selector) SetCount(v uint32) {
if m != nil {
m.Count = v
}
}
// SetKey sets key of the selector.
func (m *PlacementRule_SFGroup_Selector) SetKey(v string) {
func (m *PlacementPolicy_FilterGroup_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) {
func (m *PlacementPolicy_FilterGroup) SetFilters(v []*PlacementPolicy_FilterGroup_Filter) {
if m != nil {
m.Filters = v
}
}
// SetSelectors sets list of the selectors.
func (m *PlacementRule_SFGroup) SetSelectors(v []*PlacementRule_SFGroup_Selector) {
func (m *PlacementPolicy_FilterGroup) SetSelectors(v []*PlacementPolicy_FilterGroup_Selector) {
if m != nil {
m.Selectors = v
}
}
// SetExclude sets exclude list.
func (m *PlacementRule_SFGroup) SetExclude(v []uint32) {
func (m *PlacementPolicy_FilterGroup) SetExclude(v []uint32) {
if m != nil {
m.Exclude = v
}
}
// SetReplFactor sets replication factor of the placement rule.
func (m *PlacementRule) SetReplFactor(v uint32) {
func (m *PlacementPolicy) SetReplFactor(v uint32) {
if m != nil {
m.ReplFactor = v
}
}
// SetSfGroups sets list of the selector-filter groups.
func (m *PlacementRule) SetSfGroups(v []*PlacementRule_SFGroup) {
func (m *PlacementPolicy) SetSfGroups(v []*PlacementPolicy_FilterGroup) {
if m != nil {
m.SfGroups = v
m.FilterGroups = v
}
}

View file

@ -368,35 +368,35 @@ func (m *HeadResponse) SetVerifyHeader(v *service.ResponseVerificationHeader) {
}
// SetMatchType sets match type of the filter.
func (m *SearchRequest_Body_Query_Filter) SetMatchType(v SearchRequest_Body_Query_Filter_MatchType) {
func (m *SearchRequest_Body_Filter) SetMatchType(v SearchRequest_Body_Filter_MatchType) {
if m != nil {
m.MatchType = v
}
}
// SetName sets name of the filtering header.
func (m *SearchRequest_Body_Query_Filter) SetName(v string) {
func (m *SearchRequest_Body_Filter) SetName(v string) {
if m != nil {
m.Name = v
}
}
// SetValue sets value of the filtering header.
func (m *SearchRequest_Body_Query_Filter) SetValue(v string) {
func (m *SearchRequest_Body_Filter) SetValue(v string) {
if m != nil {
m.Value = v
}
}
// SetVersion sets version of the search query.
func (m *SearchRequest_Body_Query) SetVersion(v uint32) {
func (m *SearchRequest_Body) SetVersion(v uint32) {
if m != nil {
m.Version = v
}
}
// SetFilters sets list of the query filters.
func (m *SearchRequest_Body_Query) SetFilters(v []*SearchRequest_Body_Query_Filter) {
func (m *SearchRequest_Body) SetFilters(v []*SearchRequest_Body_Filter) {
if m != nil {
m.Filters = v
}
@ -409,13 +409,6 @@ func (m *SearchRequest_Body) SetContainerId(v *refs.ContainerID) {
}
}
// SetQuery sets search query structure.
func (m *SearchRequest_Body) SetQuery(v *SearchRequest_Body_Query) {
if m != nil {
m.Query = v
}
}
// SetBody sets body of the request.
func (m *SearchRequest) SetBody(v *SearchRequest_Body) {
if m != nil {

View file

@ -101,7 +101,7 @@ func (m *SessionToken_Body) SetObjectAddressContext(v *refs.Address) {
// SetBody sets session token body.
func (m *SessionToken) SetBody(v *SessionToken_Body) {
if m != nil {
m.Token = v
m.Body = v
}
}
@ -136,7 +136,7 @@ func (m *BearerToken_Body) SetLifetime(v *TokenLifetime) {
// SetBody sets bearer token body.
func (m *BearerToken) SetBody(v *BearerToken_Body) {
if m != nil {
m.Token = v
m.Body = v
}
}
@ -178,14 +178,14 @@ func (m *RequestMetaHeader) SetXHeaders(v []*XHeader) {
// SetSessionToken sets session token of the request.
func (m *RequestMetaHeader) SetSessionToken(v *SessionToken) {
if m != nil {
m.Token = v
m.SessionToken = v
}
}
// SetBearerToken sets bearer token of the request.
func (m *RequestMetaHeader) SetBearerToken(v *BearerToken) {
if m != nil {
m.Bearer = v
m.BearerToken = v
}
}