mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-06 03:32:34 +02:00

Some checks are pending
Docker Image CI (socket-proxy) / build (push) Waiting to run
* refactor: simplify io code and make utils module independent * fix(docker): agent and socket-proxy docker event flushing with modified reverse proxy handler * refactor: remove unused code * refactor: remove the use of logging module in most code * refactor: streamline domain mismatch check in certState function * tweak: use ecdsa p-256 for autocert * fix(tests): update health check tests for invalid host and add case for port in host * feat(acme): custom acme directory * refactor: code refactor and improved context and error handling * tweak: optimize memory usage under load * fix(oidc): restore old user matching behavior * docs: add ChatGPT assistant to README --------- Co-authored-by: yusing <yusing@6uo.me>
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
//go:build !production
|
|
|
|
package synk
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"runtime"
|
|
"sync/atomic"
|
|
"time"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/yusing/go-proxy/internal/utils/strutils"
|
|
)
|
|
|
|
var (
|
|
numReused, sizeReused uint64
|
|
numGCed, sizeGCed uint64
|
|
)
|
|
|
|
func addReused(size int) {
|
|
atomic.AddUint64(&numReused, 1)
|
|
atomic.AddUint64(&sizeReused, uint64(size))
|
|
}
|
|
|
|
func addGCed(size int) {
|
|
atomic.AddUint64(&numGCed, 1)
|
|
atomic.AddUint64(&sizeGCed, uint64(size))
|
|
}
|
|
|
|
var addCleanup = runtime.AddCleanup[[]byte, int]
|
|
|
|
func initPoolStats() {
|
|
go func() {
|
|
statsTicker := time.NewTicker(5 * time.Second)
|
|
defer statsTicker.Stop()
|
|
|
|
sig := make(chan os.Signal, 1)
|
|
signal.Notify(sig, os.Interrupt)
|
|
|
|
for {
|
|
select {
|
|
case <-sig:
|
|
return
|
|
case <-statsTicker.C:
|
|
log.Info().
|
|
Uint64("numReused", atomic.LoadUint64(&numReused)).
|
|
Str("sizeReused", strutils.FormatByteSize(atomic.LoadUint64(&sizeReused))).
|
|
Uint64("numGCed", atomic.LoadUint64(&numGCed)).
|
|
Str("sizeGCed", strutils.FormatByteSize(atomic.LoadUint64(&sizeGCed))).
|
|
Msg("bytes pool stats")
|
|
}
|
|
}
|
|
}()
|
|
}
|