Skip to content

Commit 1f10c9f

Browse files
committed
[add] more info on subscribers
1 parent e2bd8f8 commit 1f10c9f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

subscriber.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ func main() {
177177

178178
func updateCLI(nodes []radix.ClusterNode, connections []radix.Conn, node_subscriptions_count []int, tick *time.Ticker, c chan os.Signal) bool {
179179
w := new(tabwriter.Writer)
180-
w.Init(os.Stdout, 20, 0, 1, ' ', tabwriter.AlignRight)
180+
w.Init(os.Stdout, 25, 0, 1, ' ', tabwriter.AlignRight)
181181
for idx, slot := range nodes {
182182
c, err := radix.Dial("tcp", slot.Addr)
183183
if err != nil {
184184
panic(err)
185185
}
186-
fmt.Fprint(w, fmt.Sprintf("shard #%d\t", idx))
186+
fmt.Fprint(w, fmt.Sprintf("shard #%d\t", idx+1))
187187
connections = append(connections, c)
188188
}
189189
fmt.Fprint(w, "\n")
@@ -204,10 +204,18 @@ func updateCLI(nodes []radix.ClusterNode, connections []radix.Conn, node_subscri
204204
if eint != nil {
205205
fmt.Fprint(w, fmt.Sprintf("----\t"))
206206
} else {
207-
number_subscribers := node_subscriptions_count[idx]
208-
number_publishers := shard_clients - 1 - number_subscribers
209-
210-
fmt.Fprint(w, fmt.Sprintf("%d (p: %d) (s: %d)\t", shard_clients, number_publishers, number_subscribers))
207+
var pubsubList string
208+
e := c.Do(radix.FlatCmd(&pubsubList, "CLIENT", "LIST", "TYPE","PUBSUB"))
209+
if e != nil {
210+
fmt.Fprint(w, fmt.Sprintf("----\t"))
211+
}
212+
subscribersList := strings.Split(pubsubList, "\n")
213+
//fmt.Println(subscribersList)
214+
expected_subscribers := node_subscriptions_count[idx]
215+
number_subscribers := len(subscribersList)-1
216+
others := shard_clients - 1 - number_subscribers
217+
218+
fmt.Fprint(w, fmt.Sprintf("%d (other %d sub %d==%d)\t", shard_clients, others, number_subscribers, expected_subscribers))
211219
}
212220

213221
}

0 commit comments

Comments
 (0)