[#207] aclsvc: Refactor object headers read

Resolve funlen linter for readObjectHeaders method.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-04-04 12:03:19 +03:00 committed by Gitea
parent cd33a57f44
commit 9ef790f782

View file

@ -101,12 +101,18 @@ func requestHeaders(msg xHeaderSource) []eaclSDK.Header {
var errMissingOID = errors.New("object ID is missing") var errMissingOID = errors.New("object ID is missing")
// nolint: funlen
func (h *cfg) readObjectHeaders(dst *headerSource) error { func (h *cfg) readObjectHeaders(dst *headerSource) error {
switch m := h.msg.(type) { switch m := h.msg.(type) {
default: default:
panic(fmt.Sprintf("unexpected message type %T", h.msg)) panic(fmt.Sprintf("unexpected message type %T", h.msg))
case requestXHeaderSource: case requestXHeaderSource:
return h.readObjectHeadersFromRequestXHeaderSource(m, dst)
case responseXHeaderSource:
return h.readObjectHeadersResponseXHeaderSource(m, dst)
}
}
func (h *cfg) readObjectHeadersFromRequestXHeaderSource(m requestXHeaderSource, dst *headerSource) error {
switch req := m.req.(type) { switch req := m.req.(type) {
case case
*objectV2.GetRequest, *objectV2.GetRequest,
@ -148,7 +154,10 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error {
dst.objectHeaders = []eaclSDK.Header{cidHeader(cnr)} dst.objectHeaders = []eaclSDK.Header{cidHeader(cnr)}
} }
case responseXHeaderSource: return nil
}
func (h *cfg) readObjectHeadersResponseXHeaderSource(m responseXHeaderSource, dst *headerSource) error {
switch resp := m.resp.(type) { switch resp := m.resp.(type) {
default: default:
objectHeaders, completed := h.localObjectHeaders(h.cnr, h.obj) objectHeaders, completed := h.localObjectHeaders(h.cnr, h.obj)
@ -189,8 +198,6 @@ func (h *cfg) readObjectHeaders(dst *headerSource) error {
dst.objectHeaders = headersFromObject(object.NewFromV2(oV2), h.cnr, h.obj) dst.objectHeaders = headersFromObject(object.NewFromV2(oV2), h.cnr, h.obj)
} }
}
return nil return nil
} }