forked from TrueCloudLab/frostfs-sdk-go
[#155] sdk-go: Add buffer support for payloadSizeLimiter
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
bd2d350b09
commit
1af9b6d18b
3 changed files with 24 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
buffPool "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/pool"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
|
@ -45,6 +46,7 @@ type Params struct {
|
|||
// functionality. Primary usecases are providing file size when putting an object
|
||||
// with the frostfs-cli or using Content-Length header in gateways.
|
||||
SizeHint uint64
|
||||
Pool *buffPool.BufferPool
|
||||
}
|
||||
|
||||
// NewPayloadSizeLimiter returns ObjectTarget instance that restricts payload length
|
||||
|
@ -137,7 +139,13 @@ func (s *payloadSizeLimiter) initializeCurrent() {
|
|||
payloadSize = remaining % s.MaxSize
|
||||
}
|
||||
}
|
||||
s.payload = make([]byte, 0, payloadSize)
|
||||
|
||||
if s.Pool == nil {
|
||||
s.payload = make([]byte, 0, payloadSize)
|
||||
} else {
|
||||
buffer := s.Pool.Get(uint32(payloadSize))
|
||||
s.payload = buffer.Data[:0]
|
||||
}
|
||||
}
|
||||
|
||||
func (s *payloadSizeLimiter) initPayloadHashers() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue