-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcrud_byvb.go
More file actions
73 lines (64 loc) · 1.64 KB
/
crud_byvb.go
File metadata and controls
73 lines (64 loc) · 1.64 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package gocbcorex
import (
"context"
"github.com/couchbase/gocbcorex/memdx"
)
func OrchestrateSimpleVbCrud[RespT any](
ctx context.Context,
rs RetryManager,
vb VbucketRouter,
ch NotMyVbucketConfigHandler,
ecp KvEndpointClientProvider,
vbID uint16, vbServerIdx uint32,
fn func(endpoint string, client KvClient) (RespT, error),
) (RespT, error) {
return OrchestrateRetries(
ctx, rs,
func() (RespT, error) {
return OrchestrateMemdRoutingByVbucketId(ctx, vb, ch, vbID, vbServerIdx,
func(endpoint string) (RespT, error) {
return OrchestrateEndpointKvClient(ctx, ecp, endpoint, func(client KvClient) (RespT, error) {
return fn(endpoint, client)
})
})
})
}
type StatsByVbucketOptions struct {
GroupName string
VbucketID uint16
OnBehalfOf string
}
type StatsResult struct{}
type StatsDataResult struct {
Key string
Value string
}
func (cc *CrudComponent) StatsByVbucket(
ctx context.Context,
opts *StatsByVbucketOptions,
dataCb func(StatsDataResult),
) (*StatsResult, error) {
ctx, span := tracer.Start(ctx, "Stats")
defer span.End()
return OrchestrateSimpleVbCrud(
ctx, cc.retries, cc.vbs, cc.nmvHandler, cc.eclientProvider,
opts.VbucketID, 0,
func(endpoint string, client KvClient) (*StatsResult, error) {
_, err := client.Stats(ctx, &memdx.StatsRequest{
GroupName: opts.GroupName,
UtilsRequestMeta: memdx.UtilsRequestMeta{
OnBehalfOf: opts.OnBehalfOf,
},
}, func(resp *memdx.StatsDataResponse) error {
dataCb(StatsDataResult{
Key: resp.Key,
Value: resp.Value,
})
return nil
})
if err != nil {
return nil, err
}
return &StatsResult{}, nil
})
}