Skip to content

Commit

Permalink
pool: Add noop statistic
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Jun 20, 2023
1 parent 68c39ea commit bf18054
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
46 changes: 46 additions & 0 deletions pool/status.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit bf18054

Please sign in to comment.