diff --git a/pool/pool.go b/pool/pool.go index 3055946f..90c0b2de 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -1595,9 +1595,9 @@ func fillDefaultInitParams(params *InitParameters, cache *sessionCache) { return nil }) - var statistic ClientStatus - if params.statistic == nil { - // statistic is disabled by default. + // statistic is disabled by default. + var statistic = params.statistic + if statistic == nil { statistic = newNoOpClientStatusMonitor(prm.address) } diff --git a/pool/status.go b/pool/status.go new file mode 100644 index 00000000..2964690a --- /dev/null +++ b/pool/status.go @@ -0,0 +1,46 @@ +package pool + +import ( + "time" +) + +// noOpClientStatusMonitor is using by default for pool. +type noOpClientStatusMonitor struct { + addr string +} + +func newNoOpClientStatusMonitor(addr string) noOpClientStatusMonitor { + return noOpClientStatusMonitor{addr: addr} +} + +func (n noOpClientStatusMonitor) updateErrorRate(_ error) { +} + +func (n noOpClientStatusMonitor) incRequests(_ time.Duration, _ MethodIndex) { +} + +func (n noOpClientStatusMonitor) isHealthy() bool { + return true +} + +func (n noOpClientStatusMonitor) setUnhealthy() { +} + +func (n noOpClientStatusMonitor) setHealthy() { +} + +func (n noOpClientStatusMonitor) address() string { + return n.addr +} + +func (n noOpClientStatusMonitor) currentErrorRate() uint32 { + return 0 +} + +func (n noOpClientStatusMonitor) overallErrorRate() uint64 { + return 0 +} + +func (n noOpClientStatusMonitor) methodsStatus() []statusSnapshot { + return nil +}