Files
EdgeNode/internal/compressions/writer_pool_gzip.go

27 lines
585 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 (
"compress/gzip"
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
"io"
)
var sharedGzipWriterPool *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
}
sharedGzipWriterPool = NewWriterPool(maxSize, gzip.BestCompression, func(writer io.Writer, level int) (Writer, error) {
return newGzipWriter(writer, level)
})
}