[#539] getsvc: Use buffer to assemble object

To reduce memory consumption.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-07-24 13:40:47 +03:00
parent 32c77f3a23
commit 286242cad0
4 changed files with 20 additions and 7 deletions

View file

@ -49,10 +49,18 @@ func NewSimpleObjectWriter() *SimpleObjectWriter {
}
}
func (s *SimpleObjectWriter) SetPayloadBuffer(buffer []byte) {
if buffer != nil {
s.pld = buffer[:0]
}
}
func (s *SimpleObjectWriter) WriteHeader(_ context.Context, obj *objectSDK.Object) error {
s.obj = obj
s.pld = make([]byte, 0, obj.PayloadSize())
if s.pld == nil {
s.pld = make([]byte, 0, obj.PayloadSize())
}
return nil
}