Files
EdgeNode/internal/compressions/writer_pool_brotli.go

27 lines
609 B
Go
Raw Normal View History

2022-03-20 00:05:47 +08:00
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package compressions
import (
2022-07-26 09:41:43 +08:00
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
2024-03-28 17:17:34 +08:00
memutils "github.com/TeaOSLab/EdgeNode/internal/utils/mem"
2022-03-20 00:05:47 +08:00
"github.com/andybalholm/brotli"
"io"
)
var sharedBrotliWriterPool *WriterPool
func init() {
if !teaconst.IsMain {
2022-07-26 09:41:43 +08:00
return
}
2024-03-28 17:17:34 +08:00
var maxSize = memutils.SystemMemoryGB() * 256
2022-03-20 00:05:47 +08:00
if maxSize == 0 {
maxSize = 256
}
sharedBrotliWriterPool = NewWriterPool(maxSize, brotli.BestCompression, func(writer io.Writer, level int) (Writer, error) {
return newBrotliWriter(writer, level)
})
}