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

View file

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

View file

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

View file

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

View file

@ -1,97 +1,97 @@
package netmap package netmap
// SetOp sets operation of the simple filter. // 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 { if m != nil {
m.Op = v m.Op = v
} }
} }
// SetValue sets value of the simple filter. // 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 { if m != nil {
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_Value{ m.Args = &PlacementPolicy_FilterGroup_Filter_SimpleFilter_Value{
Value: v, Value: v,
} }
} }
} }
// SetFArgs sets filter args of the simple filter. // 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 { if m != nil {
m.Args = &PlacementRule_SFGroup_Filter_SimpleFilter_FArgs{ m.Args = &PlacementPolicy_FilterGroup_Filter_SimpleFilter_FArgs{
FArgs: v, FArgs: v,
} }
} }
} }
// SetFilters sets list of the simple filters. // 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 { if m != nil {
m.Filters = v m.Filters = v
} }
} }
// SeyKey sets key of the filter. // 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 { if m != nil {
m.Key = v m.Key = v
} }
} }
// SetF sets simple filter of the filter. // 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 { if m != nil {
m.F = v m.F = v
} }
} }
// SetCount sets count value of the selector. // 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 { if m != nil {
m.Count = v m.Count = v
} }
} }
// SetKey sets key of the selector. // 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 { if m != nil {
m.Key = v m.Key = v
} }
} }
// SetFilters sets list of the filters. // 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 { if m != nil {
m.Filters = v m.Filters = v
} }
} }
// SetSelectors sets list of the selectors. // 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 { if m != nil {
m.Selectors = v m.Selectors = v
} }
} }
// SetExclude sets exclude list. // SetExclude sets exclude list.
func (m *PlacementRule_SFGroup) SetExclude(v []uint32) { func (m *PlacementPolicy_FilterGroup) SetExclude(v []uint32) {
if m != nil { if m != nil {
m.Exclude = v m.Exclude = v
} }
} }
// SetReplFactor sets replication factor of the placement rule. // SetReplFactor sets replication factor of the placement rule.
func (m *PlacementRule) SetReplFactor(v uint32) { func (m *PlacementPolicy) SetReplFactor(v uint32) {
if m != nil { if m != nil {
m.ReplFactor = v m.ReplFactor = v
} }
} }
// SetSfGroups sets list of the selector-filter groups. // 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 { 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. // 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 { if m != nil {
m.MatchType = v m.MatchType = v
} }
} }
// SetName sets name of the filtering header. // 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 { if m != nil {
m.Name = v m.Name = v
} }
} }
// SetValue sets value of the filtering header. // 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 { if m != nil {
m.Value = v m.Value = v
} }
} }
// SetVersion sets version of the search query. // 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 { if m != nil {
m.Version = v m.Version = v
} }
} }
// SetFilters sets list of the query filters. // 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 { if m != nil {
m.Filters = v 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. // SetBody sets body of the request.
func (m *SearchRequest) SetBody(v *SearchRequest_Body) { func (m *SearchRequest) SetBody(v *SearchRequest_Body) {
if m != nil { if m != nil {

View file

@ -101,7 +101,7 @@ func (m *SessionToken_Body) SetObjectAddressContext(v *refs.Address) {
// SetBody sets session token body. // SetBody sets session token body.
func (m *SessionToken) SetBody(v *SessionToken_Body) { func (m *SessionToken) SetBody(v *SessionToken_Body) {
if m != nil { 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. // SetBody sets bearer token body.
func (m *BearerToken) SetBody(v *BearerToken_Body) { func (m *BearerToken) SetBody(v *BearerToken_Body) {
if m != nil { 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. // SetSessionToken sets session token of the request.
func (m *RequestMetaHeader) SetSessionToken(v *SessionToken) { func (m *RequestMetaHeader) SetSessionToken(v *SessionToken) {
if m != nil { if m != nil {
m.Token = v m.SessionToken = v
} }
} }
// SetBearerToken sets bearer token of the request. // SetBearerToken sets bearer token of the request.
func (m *RequestMetaHeader) SetBearerToken(v *BearerToken) { func (m *RequestMetaHeader) SetBearerToken(v *BearerToken) {
if m != nil { if m != nil {
m.Bearer = v m.BearerToken = v
} }
} }