switch to universal client
Some checks failed
codeql / analyze (go) (push) Failing after 1m30s
build / test (push) Failing after 5m13s
build / lint (push) Successful in 9m40s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-10-05 16:11:46 +03:00
parent 256e61a437
commit 87e2e2b947
7 changed files with 261 additions and 220 deletions

View File

@@ -3,7 +3,8 @@ package redis
import (
"time"
"github.com/redis/go-redis/v9"
goredis "github.com/redis/go-redis/v9"
"go.unistack.org/micro/v3/meter"
)
var (
@@ -13,29 +14,23 @@ var (
PoolConnTotalCurrent = "pool_conn_total_current"
PoolConnIdleCurrent = "pool_conn_idle_current"
PoolConnStaleTotal = "pool_conn_stale_total"
meterRequestTotal = "request_total"
meterRequestLatencyMicroseconds = "latency_microseconds"
meterRequestDurationSeconds = "request_duration_seconds"
)
type Statser interface {
PoolStats() *redis.PoolStats
PoolStats() *goredis.PoolStats
}
func (r *Store) statsMeter() {
var st Statser
if r.cli.Client != nil {
st = r.cli.Client
} else if r.cli.ClusterClient != nil {
st = r.cli.ClusterClient
if r.cli != nil {
st = r.cli
} else {
return
}
go func() {
ticker := time.NewTicker(DefaultMeterStatsInterval)
ticker := time.NewTicker(meter.DefaultMeterStatsInterval)
defer ticker.Stop()
for {