-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
accessor.go
42 lines (34 loc) · 1009 Bytes
/
accessor.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
35
36
37
38
39
40
41
42
package spanstatsaccessor
import (
"context"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
)
// LocalAccessor is an implementation of spanstats.Accessor that is meant
// to provide access to span span stats to servers that are co-located on the KV
// node.
type LocalAccessor struct {
spanStatsServer serverpb.SpanStatsServer
}
// New returns a new instance of AccessorImpl.
func New(server serverpb.SpanStatsServer) *LocalAccessor {
return &LocalAccessor{spanStatsServer: server}
}
// SpanStats implements the spanstats.Accessor interface.
func (a *LocalAccessor) SpanStats(
ctx context.Context, startKey,
endKey roachpb.Key, nodeID roachpb.NodeID,
) (*serverpb.InternalSpanStatsResponse, error) {
res, err := a.spanStatsServer.GetSpanStats(ctx,
&serverpb.InternalSpanStatsRequest{
Span: roachpb.Span{
Key: startKey,
EndKey: endKey,
},
NodeID: nodeID,
})
if err != nil {
return nil, err
}
return res, nil
}