From 0fe6b9adbb721353b27148853a48bce476d2b8cb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 26 Apr 2024 11:54:35 +0300 Subject: [PATCH] [#76] Make setter names more consistent This will make the transition to a new codegen more seamless. 1. Setter should be named as the field itself. 2. Setter should accept 1 parameter. Signed-off-by: Evgenii Stratonikov --- acl/convert.go | 4 ++-- acl/grpc/types.go | 8 ++++---- apemanager/convert.go | 4 ++-- apemanager/grpc/service.go | 4 ++-- object/convert.go | 6 +++--- object/grpc/service.go | 12 ++++++------ refs/convert.go | 2 +- refs/grpc/types.go | 4 ++-- session/convert.go | 11 +++++++---- session/grpc/types.go | 17 +++++++---------- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/acl/convert.go b/acl/convert.go index 3020f4d..342c110 100644 --- a/acl/convert.go +++ b/acl/convert.go @@ -164,7 +164,7 @@ func (f *HeaderFilter) ToGRPCMessage() grpc.Message { m.SetKey(f.key) m.SetValue(f.value) - m.SetHeader(HeaderTypeToGRPCField(f.hdrType)) + m.SetHeaderType(HeaderTypeToGRPCField(f.hdrType)) m.SetMatchType(MatchTypeToGRPCField(f.matchType)) } @@ -427,7 +427,7 @@ func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message { m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime)) m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable)) - m.SetImpersonate(bt.impersonate) + m.SetAllowImpersonate(bt.impersonate) } return m diff --git a/acl/grpc/types.go b/acl/grpc/types.go index b07f893..ce50e2f 100644 --- a/acl/grpc/types.go +++ b/acl/grpc/types.go @@ -39,8 +39,8 @@ func (m *EACLRecord) SetTargets(v []*EACLRecord_Target) { m.Targets = v } -// SetHeader sets header type of the eACL filter. -func (m *EACLRecord_Filter) SetHeader(v HeaderType) { +// SetHeaderType sets header type of the eACL filter. +func (m *EACLRecord_Filter) SetHeaderType(v HeaderType) { m.HeaderType = v } @@ -84,8 +84,8 @@ func (m *BearerToken_Body) SetLifetime(v *BearerToken_Body_TokenLifetime) { m.Lifetime = v } -// SetImpersonate allows impersonate. -func (m *BearerToken_Body) SetImpersonate(v bool) { +// SetAllowImpersonate allows impersonate. +func (m *BearerToken_Body) SetAllowImpersonate(v bool) { m.AllowImpersonate = v } diff --git a/apemanager/convert.go b/apemanager/convert.go index 12b087c..f1cbcda 100644 --- a/apemanager/convert.go +++ b/apemanager/convert.go @@ -202,7 +202,7 @@ func (respBody *AddChainResponseBody) ToGRPCMessage() grpc.Message { if respBody != nil { respBodygrpc = new(apemanager.AddChainResponse_Body) - respBodygrpc.SetChainID(respBody.GetChainID()) + respBodygrpc.SetChainId(respBody.GetChainID()) } return respBodygrpc @@ -255,7 +255,7 @@ func (reqBody *RemoveChainRequestBody) ToGRPCMessage() grpc.Message { reqBodygrpc = new(apemanager.RemoveChainRequest_Body) reqBodygrpc.SetTarget(reqBody.target.ToGRPCMessage().(*apemanager.ChainTarget)) - reqBodygrpc.SetChainID(reqBody.GetChainID()) + reqBodygrpc.SetChainId(reqBody.GetChainID()) } return reqBodygrpc diff --git a/apemanager/grpc/service.go b/apemanager/grpc/service.go index 89ffa71..c07bceb 100644 --- a/apemanager/grpc/service.go +++ b/apemanager/grpc/service.go @@ -24,7 +24,7 @@ func (r *AddChainRequest) SetVerifyHeader(vh *session_grpc.RequestVerificationHe r.VerifyHeader = vh } -func (rb *AddChainResponse_Body) SetChainID(chainID []byte) { +func (rb *AddChainResponse_Body) SetChainId(chainID []byte) { rb.ChainId = chainID } @@ -44,7 +44,7 @@ func (rb *RemoveChainRequest_Body) SetTarget(t *ChainTarget) { rb.Target = t } -func (rb *RemoveChainRequest_Body) SetChainID(chainID []byte) { +func (rb *RemoveChainRequest_Body) SetChainId(chainID []byte) { rb.ChainId = chainID } diff --git a/object/convert.go b/object/convert.go index 9b266ac..f19cc09 100644 --- a/object/convert.go +++ b/object/convert.go @@ -901,7 +901,7 @@ func (r *GetResponseBody) ToGRPCMessage() grpc.Message { case *SplitInfo: m.SetSplitInfo(t.ToGRPCMessage().(*object.SplitInfo)) case *ECInfo: - m.SetECInfo(t.ToGRPCMessage().(*object.ECInfo)) + m.SetEcInfo(t.ToGRPCMessage().(*object.ECInfo)) default: panic(fmt.Sprintf("unknown get object part %T", t)) } @@ -1486,7 +1486,7 @@ func (r *HeadResponseBody) ToGRPCMessage() grpc.Message { case *SplitInfo: m.SetSplitInfo(v.ToGRPCMessage().(*object.SplitInfo)) case *ECInfo: - m.SetECInfo(v.ToGRPCMessage().(*object.ECInfo)) + m.SetEcInfo(v.ToGRPCMessage().(*object.ECInfo)) default: panic(fmt.Sprintf("unknown head part %T", v)) } @@ -1963,7 +1963,7 @@ func (r *GetRangeResponseBody) ToGRPCMessage() grpc.Message { case *SplitInfo: m.SetSplitInfo(v.ToGRPCMessage().(*object.SplitInfo)) case *ECInfo: - m.SetECInfo(v.ToGRPCMessage().(*object.ECInfo)) + m.SetEcInfo(v.ToGRPCMessage().(*object.ECInfo)) default: panic(fmt.Sprintf("unknown get range part %T", v)) } diff --git a/object/grpc/service.go b/object/grpc/service.go index 49f160b..3ff1f3a 100644 --- a/object/grpc/service.go +++ b/object/grpc/service.go @@ -78,8 +78,8 @@ func (m *GetResponse_Body) SetSplitInfo(v *SplitInfo) { } } -// SetECInfo sets part of the object payload. -func (m *GetResponse_Body) SetECInfo(v *ECInfo) { +// SetEcInfo sets part of the object payload. +func (m *GetResponse_Body) SetEcInfo(v *ECInfo) { m.ObjectPart = &GetResponse_Body_EcInfo{ EcInfo: v, } @@ -282,8 +282,8 @@ func (m *HeadResponse_Body) SetSplitInfo(v *SplitInfo) { } } -// SetECInfo sets meta info about the erasure coded object. -func (m *HeadResponse_Body) SetECInfo(v *ECInfo) { +// SetEcInfo sets meta info about the erasure coded object. +func (m *HeadResponse_Body) SetEcInfo(v *ECInfo) { m.Head = &HeadResponse_Body_EcInfo{ EcInfo: v, } @@ -435,8 +435,8 @@ func (m *GetRangeResponse_Body) SetSplitInfo(v *SplitInfo) { } } -// SetECInfo sets meta info about the erasure-coded object. -func (m *GetRangeResponse_Body) SetECInfo(v *ECInfo) { +// SetEcInfo sets meta info about the erasure-coded object. +func (m *GetRangeResponse_Body) SetEcInfo(v *ECInfo) { m.RangePart = &GetRangeResponse_Body_EcInfo{ EcInfo: v, } diff --git a/refs/convert.go b/refs/convert.go index b2c353c..6f06783 100644 --- a/refs/convert.go +++ b/refs/convert.go @@ -196,7 +196,7 @@ func (c *Checksum) ToGRPCMessage() grpc.Message { if c != nil { m = new(refs.Checksum) - m.SetChecksumType(ChecksumTypeToGRPC(c.typ)) + m.SetType(ChecksumTypeToGRPC(c.typ)) m.SetSum(c.sum) } diff --git a/refs/grpc/types.go b/refs/grpc/types.go index 843a2ee..cdb69aa 100644 --- a/refs/grpc/types.go +++ b/refs/grpc/types.go @@ -25,8 +25,8 @@ func (x *Address) SetObjectId(v *ObjectID) { x.ObjectId = v } -// SetChecksumType in generic checksum structure. -func (x *Checksum) SetChecksumType(v ChecksumType) { +// SetType in generic checksum structure. +func (x *Checksum) SetType(v ChecksumType) { x.Type = v } diff --git a/session/convert.go b/session/convert.go index 870e208..bbfe070 100644 --- a/session/convert.go +++ b/session/convert.go @@ -383,7 +383,7 @@ func (r *RequestMetaHeader) ToGRPCMessage() grpc.Message { m.SetEpoch(r.epoch) m.SetTtl(r.ttl) m.SetOrigin(r.origin.ToGRPCMessage().(*session.RequestMetaHeader)) - m.SetNetworkMagic(r.netMagic) + m.SetMagicNumber(r.netMagic) } return m @@ -674,7 +674,10 @@ func (c *ObjectSessionContext) ToGRPCMessage() grpc.Message { m = new(session.ObjectSessionContext) m.SetVerb(ObjectSessionVerbToGRPCField(c.verb)) - m.SetTarget(c.cnr.ToGRPCMessage().(*refsGRPC.ContainerID), refs.ObjectIDListToGRPCMessage(c.objs)) + m.SetTarget(&session.ObjectSessionContext_Target{ + Container: c.cnr.ToGRPCMessage().(*refsGRPC.ContainerID), + Objects: refs.ObjectIDListToGRPCMessage(c.objs), + }) } return m @@ -724,9 +727,9 @@ func (t *TokenBody) ToGRPCMessage() grpc.Message { case nil: m.Context = nil case *ObjectSessionContext: - m.SetObjectSessionContext(typ.ToGRPCMessage().(*session.ObjectSessionContext)) + m.SetObject(typ.ToGRPCMessage().(*session.ObjectSessionContext)) case *ContainerSessionContext: - m.SetContainerSessionContext(typ.ToGRPCMessage().(*session.ContainerSessionContext)) + m.SetContainer(typ.ToGRPCMessage().(*session.ContainerSessionContext)) } m.SetOwnerId(t.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) diff --git a/session/grpc/types.go b/session/grpc/types.go index bcc92d1..857c45e 100644 --- a/session/grpc/types.go +++ b/session/grpc/types.go @@ -52,25 +52,22 @@ func (m *SessionToken_Body) SetSessionKey(v []byte) { } // SetObjectAddressContext sets object context of the session token. -func (m *SessionToken_Body) SetObjectSessionContext(v *ObjectSessionContext) { +func (m *SessionToken_Body) SetObject(v *ObjectSessionContext) { m.Context = &SessionToken_Body_Object{ Object: v, } } -// SetContainerSessionContext sets container context of the session token. -func (m *SessionToken_Body) SetContainerSessionContext(v *ContainerSessionContext) { +// SetContainer sets container context of the session token. +func (m *SessionToken_Body) SetContainer(v *ContainerSessionContext) { m.Context = &SessionToken_Body_Container{ Container: v, } } // SetTarget specifies objects involved in the object session. -func (m *ObjectSessionContext) SetTarget(cnr *refs.ContainerID, objs []*refs.ObjectID) { - m.Target = &ObjectSessionContext_Target{ - Container: cnr, - Objects: objs, - } +func (m *ObjectSessionContext) SetTarget(tgt *ObjectSessionContext_Target) { + m.Target = tgt } // SetVerb sets type of request for which the token is issued. @@ -147,8 +144,8 @@ func (m *RequestMetaHeader) GetNetworkMagic() uint64 { return 0 } -// SetNetworkMagic sets NeoFS network magic. -func (m *RequestMetaHeader) SetNetworkMagic(v uint64) { +// SetMagicNumber sets NeoFS network magic. +func (m *RequestMetaHeader) SetMagicNumber(v uint64) { m.MagicNumber = v } -- 2.45.2