-
Notifications
You must be signed in to change notification settings - Fork 107
/
stats.go
34 lines (27 loc) · 895 Bytes
/
stats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package syncer
import "context"
// StatsCollector is a ReadSyncer which collects call statistics.
type StatsCollector struct {
SyncGetCount int
SyncGetPrefixesCount int
SyncIterateCount int
rs ReadSyncer
}
// NewStatsCollector creates a new no-op read syncer.
func NewStatsCollector(rs ReadSyncer) *StatsCollector {
return &StatsCollector{
rs: rs,
}
}
func (c *StatsCollector) SyncGet(ctx context.Context, request *GetRequest) (*ProofResponse, error) {
c.SyncGetCount++
return c.rs.SyncGet(ctx, request)
}
func (c *StatsCollector) SyncGetPrefixes(ctx context.Context, request *GetPrefixesRequest) (*ProofResponse, error) {
c.SyncGetPrefixesCount++
return c.rs.SyncGetPrefixes(ctx, request)
}
func (c *StatsCollector) SyncIterate(ctx context.Context, request *IterateRequest) (*ProofResponse, error) {
c.SyncIterateCount++
return c.rs.SyncIterate(ctx, request)
}