perf(cmpp): instrument inbound flow and unbatch submit worker

This commit is contained in:
hectorzhao
2026-08-20 11:27:35 +08:00
parent c4f36fc50d
commit b9a71fe0b9
23 changed files with 760 additions and 138 deletions
+13
View File
@@ -67,6 +67,7 @@ func main() {
worker.Stream = getenv("GATEWAY_SUBMIT_STREAM", "gateway.submit.commands")
worker.Group = getenv("GATEWAY_SUBMIT_GROUP", "cmpp-gateway")
worker.Consumer = getenv("GATEWAY_SUBMIT_CONSUMER", "gateway-1")
worker.Concurrency = positiveEnvInt("GATEWAY_SUBMIT_WORKER_CONCURRENCY", 64)
worker.APIBaseURL = apiBaseURL
go func() {
log.Printf("cmpp gateway submit worker consuming stream=%s group=%s consumer=%s", worker.Stream, worker.Group, worker.Consumer)
@@ -85,6 +86,10 @@ func main() {
UpstreamDesired: desired, UpstreamConnected: connected,
DownstreamConnected: inbound.ActiveConnectionCount(), SubmitWorkerUp: worker != nil,
}
if worker != nil {
snapshot.SubmitWorkerConcurrency = worker.ConfiguredConcurrency()
snapshot.SubmitWorkerInFlight = worker.InFlight()
}
if worker == nil || worker.Redis == nil {
return snapshot
}
@@ -141,6 +146,14 @@ func getenv(key string, fallback string) string {
return value
}
func positiveEnvInt(key string, fallback int) int {
value, err := strconv.Atoi(os.Getenv(key))
if err != nil || value <= 0 {
return fallback
}
return value
}
func hostname() string {
name, err := os.Hostname()
if err != nil || name == "" {