[#73] object: Implement Get\Head requests for EC object

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-04-22 13:25:29 +03:00
parent 4a330a5706
commit df9b65324a
5 changed files with 171 additions and 8 deletions

View file

@ -57,6 +57,12 @@ const (
splitInfoLastPartField = 2
splitInfoLinkField = 3
ecInfoChunksField = 1
ecChunkIDField = 1
ecChunkIndexField = 2
ecChunkTotalField = 3
getReqBodyAddressField = 1
getReqBodyRawFlagField = 2
@ -67,6 +73,7 @@ const (
getRespBodyInitField = 1
getRespBodyChunkField = 2
getRespBodySplitInfoField = 3
getRespBodyECInfoField = 4
putReqInitObjectIDField = 1
putReqInitSignatureField = 2
@ -89,6 +96,7 @@ const (
headRespBodyHeaderField = 1
headRespBodyShortHeaderField = 2
headRespBodySplitInfoField = 3
headRespBodyECInfoField = 4
searchFilterMatchField = 1
searchFilterNameField = 2
@ -451,6 +459,74 @@ func (s *SplitInfo) Unmarshal(data []byte) error {
return message.Unmarshal(s, data, new(object.SplitInfo))
}
func (e *ECInfo) StableMarshal(buf []byte) []byte {
if e == nil {
return []byte{}
}
if buf == nil {
buf = make([]byte, e.StableSize())
}
var offset int
for i := range e.Chunks {
offset += proto.NestedStructureMarshal(ecInfoChunksField, buf[offset:], &e.Chunks[i])
}
return buf
}
func (e *ECInfo) StableSize() (size int) {
if e == nil {
return 0
}
for i := range e.Chunks {
size += proto.NestedStructureSize(ecInfoChunksField, &e.Chunks[i])
}
return size
}
func (e *ECInfo) Unmarshal(data []byte) error {
return message.Unmarshal(e, data, new(object.ECInfo))
}
func (c *ECChunk) StableMarshal(buf []byte) []byte {
if c == nil {
return []byte{}
}
if buf == nil {
buf = make([]byte, c.StableSize())
}
var offset int
offset += proto.NestedStructureMarshal(ecChunkIDField, buf[offset:], &c.ID)
offset += proto.UInt32Marshal(ecChunkIndexField, buf[offset:], c.Index)
proto.UInt32Marshal(ecChunkTotalField, buf[offset:], c.Total)
return buf
}
func (c *ECChunk) StableSize() (size int) {
if c == nil {
return 0
}
size += proto.NestedStructureSize(ecChunkIDField, &c.ID)
size += proto.UInt32Size(ecChunkIndexField, c.Index)
size += proto.UInt32Size(ecChunkTotalField, c.Total)
return size
}
func (c *ECChunk) Unmarshal(data []byte) error {
return message.Unmarshal(c, data, new(object.ECInfo_Chunk))
}
func (r *GetRequestBody) StableMarshal(buf []byte) []byte {
if r == nil {
return []byte{}
@ -536,6 +612,8 @@ func (r *GetResponseBody) StableMarshal(buf []byte) []byte {
}
case *SplitInfo:
proto.NestedStructureMarshal(getRespBodySplitInfoField, buf, v)
case *ECInfo:
proto.NestedStructureMarshal(getRespBodyECInfoField, buf, v)
default:
panic("unknown one of object get response body type")
}
@ -558,6 +636,8 @@ func (r *GetResponseBody) StableSize() (size int) {
}
case *SplitInfo:
size += proto.NestedStructureSize(getRespBodySplitInfoField, v)
case *ECInfo:
size += proto.NestedStructureSize(getRespBodyECInfoField, v)
default:
panic("unknown one of object get response body type")
}
@ -796,6 +876,10 @@ func (r *HeadResponseBody) StableMarshal(buf []byte) []byte {
if v != nil {
proto.NestedStructureMarshal(headRespBodySplitInfoField, buf, v)
}
case *ECInfo:
if v != nil {
proto.NestedStructureMarshal(headRespBodyECInfoField, buf, v)
}
default:
panic("unknown one of object put request body type")
}
@ -822,6 +906,10 @@ func (r *HeadResponseBody) StableSize() (size int) {
if v != nil {
size += proto.NestedStructureSize(headRespBodySplitInfoField, v)
}
case *ECInfo:
if v != nil {
size += proto.NestedStructureSize(headRespBodyECInfoField, v)
}
default:
panic("unknown one of object put request body type")
}