Deduplicate object request fields' handling#4007
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4007 +/- ##
==========================================
- Coverage 27.78% 27.71% -0.07%
==========================================
Files 681 681
Lines 46797 46725 -72
==========================================
- Hits 13001 12951 -50
+ Misses 32557 32551 -6
+ Partials 1239 1223 -16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| return code, nil | ||
| } | ||
|
|
||
| func checkRequiredObjectAddress(m *protorefs.Address) (cid.ID, oid.ID, string) { |
There was a problem hiding this comment.
why returning string, not an error?
There was a problem hiding this comment.
it's written to status message which is of string type
There was a problem hiding this comment.
Still string is confusing here and makes using this function unobvious (its declaration reads as error-free), in its essence it's exactly an error, let the caller deal with how it's stringified or not.
| // first object not defined, unexpected, do not attach any header | ||
| } | ||
| } | ||
| case *protoobject.SearchRequest: |
There was a problem hiding this comment.
why dont we have SearchV2Request there? it also has cID
There was a problem hiding this comment.
it's never been there 🤷♂️
refs nspcc-dev/neofs-testcases#1327
| } | ||
|
|
||
| func WithOID(v *oid.ID) Option { | ||
| func WithOID(v oid.ID) Option { |
There was a problem hiding this comment.
it could be, but i decided to change everything related to CID/OID in one change
| return RequestInfo{}, user.ID{}, fmt.Errorf("invalid container ID: %w", err) | ||
| } | ||
|
|
||
| func (b Service) PutRequestToInfo(request *protoobject.PutRequest, initPart *protoobject.PutRequest_Body_Init, cID cid.ID, obj oid.ID) (RequestInfo, user.ID, error) { |
There was a problem hiding this comment.
I'd prefer cnr here, both cID and cnr were used previously, so some code has to be changed anyway and cnr is used in most of other places.
| return code, nil | ||
| } | ||
|
|
||
| func checkRequiredObjectAddress(m *protorefs.Address) (cid.ID, oid.ID, string) { |
There was a problem hiding this comment.
Still string is confusing here and makes using this function unobvious (its declaration reads as error-free), in its essence it's exactly an error, let the caller deal with how it's stringified or not.
| return cnr, obj, "" | ||
| } | ||
|
|
||
| func checkRequiredContainerID(m *protorefs.ContainerID) (cid.ID, string) { |
There was a problem hiding this comment.
Same for other functions here, it's Go, "smth + error" is what everyone expects.
| if reqInfo, objOwner, err := s.reqInfoProc.PutRequestToInfo(req); err != nil { | ||
| part, ok := req.Body.GetObjectPart().(*protoobject.PutRequest_Body_Init_) | ||
| if !ok { | ||
| if err = ps.forwardRequest(req); err != nil { |
There was a problem hiding this comment.
Just as an idea, maybe it's worth moving init handling outside of the loop, currently it's not immediately clear why we're forwarding here.
| HeadRequestToInfo(*protoobject.HeadRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error) | ||
| GetRequestToInfo(*protoobject.GetRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error) | ||
| RangeRequestToInfo(*protoobject.GetRangeRequest, cid.ID, oid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error) | ||
| SearchV2RequestToInfo(*protoobject.SearchV2Request, cid.ID, *protosession.SessionTokenV2, *sessionv2.Token, *protosession.SessionToken, *session.Object, *protoacl.BearerToken, *bearer.Token) (aclsvc.RequestInfo, error) |
There was a problem hiding this comment.
I don't like how we're mixing proto/non-proto here (technically they're duplicating) and the overall parameter count becomes bigger than desired. Can we at least avoid proto/non-proto in the same call?
|
|
||
| if meta.SessionTokenV2 != nil { | ||
| var token sessionv2.Token | ||
| if err := token.FromProtoMessage(meta.SessionTokenV2); err != nil { |
There was a problem hiding this comment.
This means we're decoding tokens for all requests instead of taking the decoded one from cache, that's kinda regression.
53ac095 to
da26707
Compare
Check once and reuse wherever needed. Signed-off-by: cthulhurider <ctulhurider@gmail.com>
Stale since e4a034c. Signed-off-by: cthulhurider <ctulhurider@gmail.com>
Check once and reuse wherever needed. Signed-off-by: cthulhurider <ctulhurider@gmail.com>
da26707 to
6e15806
Compare
No description provided.