summaryrefslogtreecommitdiff
path: root/internal/clients/stats.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-09 21:10:29 +0300
committerPaul Buetow <paul@buetow.org>2021-10-10 13:36:41 +0300
commit97747ea0f3178f7f5890512d483fdccaa82846b0 (patch)
tree9ff1335ca26afc90e55fd6de416457e252d75a35 /internal/clients/stats.go
parent7a7169791a64190e1002e38bc9c04ad0d5c1ce1f (diff)
vetting and linting and some code restyling
Diffstat (limited to 'internal/clients/stats.go')
-rw-r--r--internal/clients/stats.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/internal/clients/stats.go b/internal/clients/stats.go
index fbef572..1315aea 100644
--- a/internal/clients/stats.go
+++ b/internal/clients/stats.go
@@ -36,9 +36,10 @@ func newTailStats(servers int) *stats {
// Start starts printing client connection stats every time a signal is recieved or
// connection count has changed.
-func (s *stats) Start(ctx context.Context, throttleCh <-chan struct{}, statsCh <-chan string, quiet bool) {
- var connectedLast int
+func (s *stats) Start(ctx context.Context, throttleCh <-chan struct{},
+ statsCh <-chan string, quiet bool) {
+ var connectedLast int
for {
var force bool
var messages []string
@@ -94,7 +95,9 @@ func (s *stats) printStatsDueInterrupt(messages []string) {
dlog.Client.Resume()
}
-func (s *stats) statsData(connected, newConnections int, throttle int) map[string]interface{} {
+func (s *stats) statsData(connected, newConnections int,
+ throttle int) map[string]interface{} {
+
percConnected := percentOf(float64(s.servers), float64(connected))
data := make(map[string]interface{})
@@ -112,7 +115,6 @@ func (s *stats) statsData(connected, newConnections int, throttle int) map[strin
func (s *stats) statsLine(connected, newConnections int, throttle int) string {
sb := strings.Builder{}
-
i := 0
for k, v := range s.statsData(connected, newConnections, throttle) {
if i > 0 {
@@ -123,7 +125,6 @@ func (s *stats) statsLine(connected, newConnections int, throttle int) string {
sb.WriteString(fmt.Sprintf("%v", v))
i++
}
-
return sb.String()
}