mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-24 05:10:43 +00:00
- Add Bearer Token authentication, supporting tunnel access control via the --auth-bearer parameter - Refactor large modules into smaller, more focused components to improve code maintainability - Update dependency versions, including golang.org/x/crypto, golang.org/x/net, etc. - Add SilenceUsage and SilenceErrors configuration for all CLI commands - Modify connector configuration structure to support the new authentication method - Update recent change log in README with new feature descriptions BREAKING CHANGE: Authentication via Bearer Token is now supported, requiring the new --auth-bearer parameter
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package pool
|
|
|
|
import (
|
|
"bufio"
|
|
"sync"
|
|
)
|
|
|
|
// BufioReaderPool provides a pool of bufio.Reader instances.
|
|
var BufioReaderPool = sync.Pool{
|
|
New: func() interface{} {
|
|
return bufio.NewReaderSize(nil, 32*1024)
|
|
},
|
|
}
|
|
|
|
// BufioWriterPool provides a pool of bufio.Writer instances.
|
|
var BufioWriterPool = sync.Pool{
|
|
New: func() interface{} {
|
|
return bufio.NewWriterSize(nil, 4096)
|
|
},
|
|
}
|
|
|
|
// GetReader gets a bufio.Reader from the pool and resets it to read from r.
|
|
func GetReader(r interface{}) *bufio.Reader {
|
|
reader := BufioReaderPool.Get().(*bufio.Reader)
|
|
if resetter, ok := r.(interface{ Reset(interface{}) }); ok {
|
|
resetter.Reset(r)
|
|
}
|
|
return reader
|
|
}
|
|
|
|
// PutReader returns a bufio.Reader to the pool.
|
|
func PutReader(reader *bufio.Reader) {
|
|
BufioReaderPool.Put(reader)
|
|
}
|
|
|
|
// GetWriter gets a bufio.Writer from the pool and resets it to write to w.
|
|
func GetWriter(w interface{}) *bufio.Writer {
|
|
writer := BufioWriterPool.Get().(*bufio.Writer)
|
|
if resetter, ok := w.(interface{ Reset(interface{}) }); ok {
|
|
resetter.Reset(w)
|
|
}
|
|
return writer
|
|
}
|
|
|
|
// PutWriter returns a bufio.Writer to the pool.
|
|
func PutWriter(writer *bufio.Writer) {
|
|
BufioWriterPool.Put(writer)
|
|
}
|