Add rpc proxy request

This commit is contained in:
9seconds
2018-07-02 09:15:03 +03:00
parent 0e2898f6be
commit 96bb6fbe98
4 changed files with 137 additions and 28 deletions
+32
View File
@@ -0,0 +1,32 @@
package bufferpool
import (
"bytes"
"sync"
)
const bufferPoolSize = 4 * 1024
var bufferPool sync.Pool
func Get() *bytes.Buffer {
buf := bufferPool.Get().(*bytes.Buffer)
buf.Reset()
return buf
}
func Return(buf *bytes.Buffer) {
bufferPool.Put(buf)
}
func init() {
bufferPool = sync.Pool{
New: func() interface{} {
buf := &bytes.Buffer{}
buf.Grow(bufferPoolSize)
return buf
},
}
}