MSP-8974 add download flow, server migration to http

This commit is contained in:
chashintv committed 2026-11-19 12:48:34 +03:00
1 parent 4e01670ceb
commit 9aeb791c53
46 files changed
+5102 -124

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package buffer
import (
"net/http"
"sync"
)
// pool is a global sync.Pool for reusing Buffer instances.
// It reduces memory allocation overhead by pooling Buffer objects.
var pool = sync.Pool{
New: func() any {
return New()
},
}
// Acquire retrieves a Buffer from the pool and initializes it with the given ResponseWriter.
// It is safe for concurrent use and should be paired with Release.
func Acquire(w http.ResponseWriter) *Buffer {
var buffer *Buffer
var ok bool
buffer, ok = pool.Get().(*Buffer)
if !ok {
buffer = New()
}
buffer.Reset(w)
return buffer
}
// Release returns a Buffer to the pool for reuse.
// It should be called after the Buffer is no longer needed.
func Release(w *Buffer) {
pool.Put(w)
}