Skip to content

Commit 32040e0

Browse files
committed
ovsdb: add ClientStats type and Client.Stats method
1 parent 3907097 commit 32040e0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ovsdb/client.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ func (c *Client) Close() error {
109109
return err
110110
}
111111

112+
// Stats returns a ClientStats with current statistics for the Cient.
113+
func (c *Client) Stats() ClientStats {
114+
var s ClientStats
115+
116+
c.cbMu.RLock()
117+
defer c.cbMu.RUnlock()
118+
119+
s.Callbacks.Current = len(c.callbacks)
120+
121+
return s
122+
}
123+
124+
// ClientStats contains statistics about a Client.
125+
type ClientStats struct {
126+
// Statistics about the Client's internal callbacks.
127+
Callbacks struct {
128+
// The number of callback hooks currently registered and waiting
129+
// for RPC responses.
130+
Current int
131+
}
132+
}
133+
112134
// rpc performs a single RPC request, and checks the response for errors.
113135
func (c *Client) rpc(ctx context.Context, method string, out interface{}, args ...interface{}) error {
114136
// Was the context canceled before sending the RPC?

0 commit comments

Comments
 (0)