Skip to content

Commit c1ed003

Browse files
committed
refactor index manager service
Signed-off-by: kpango <[email protected]>
1 parent c58cc15 commit c1ed003

File tree

221 files changed

+5423
-1470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+5423
-1470
lines changed

.golangci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ linters:
149149
- path: internal/errors/errors_benchmark_test\.go
150150
linters:
151151
- depguard
152+
<<<<<<< HEAD
152153
- path: internal/test/comparator/standard\.go
154+
=======
155+
- path: internal/sync/alias\.go
156+
linters:
157+
- depguard
158+
- path: hack/benchmark/src/singleflight/singleflight_bench_test\.go
159+
>>>>>>> refactor/manager-index/small-refactor
153160
linters:
154161
- depguard
155162
linters-settings:
@@ -169,6 +176,14 @@ linters-settings:
169176
rules:
170177
main:
171178
deny:
179+
- pkg: "sync"
180+
desc: "sync is allowed only by internal/sync"
181+
- pkg: "golang.org/x/sync"
182+
desc: "golang.org/x/sync is allowed only by internal/sync"
183+
- pkg: "golang.org/x/sync/singleflight"
184+
desc: "golang.org/x/sync/singleflight is allowed only by internal/sync/singleflight"
185+
- pkg: "golang.org/x/sync/semaphore"
186+
desc: "golang.org/x/sync/semaphore is allowed only by internal/sync/semaphore"
172187
- pkg: "errors"
173188
desc: "errors is allowed only by internal/errors"
174189
- pkg: "k8s.io/apimachinery/pkg/api/errors"

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4750,7 +4750,7 @@
47504750
- :white_check_mark: add internal/config/ngt test ([#554](https://github.com/vdaas/vald/pull/554))
47514751
- :white_check_mark: internal/cache/cacher test ([#553](https://github.com/vdaas/vald/pull/553))
47524752
- :white_check_mark: Add test case for `internal/file` ([#550](https://github.com/vdaas/vald/pull/550))
4753-
- :white_check_mark: add internal/singleflight test ([#542](https://github.com/vdaas/vald/pull/542))
4753+
- :white_check_mark: add internal/sync/singleflight test ([#542](https://github.com/vdaas/vald/pull/542))
47544754
- not to force rebuild gotests ([#548](https://github.com/vdaas/vald/pull/548))
47554755
- :pencil: Add use case document ([#482](https://github.com/vdaas/vald/pull/482))
47564756
- :white_check_mark: add internal/log/mock/retry test ([#549](https://github.com/vdaas/vald/pull/549))
@@ -5272,7 +5272,7 @@
52725272
- internal gRPC client for Vald
52735273
- Cassandra NewConvictionPolicy
52745274
- dicoverer now returns clone object
5275-
- new internal/singleflight package
5275+
- new internal/sync/singleflight package
52765276
- new internal/net package
52775277
- coding guideline
52785278

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ clean:
361361
license:
362362
GOPRIVATE=$(GOPRIVATE) \
363363
MAINTAINER=$(MAINTAINER) \
364-
go run -mod=readonly hack/license/gen/main.go ./
364+
go run -mod=readonly hack/license/gen/main.go $(ROOTDIR)
365365

366366
.PHONY: init
367367
## initialize development environment

Makefile.d/proto.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ $(PBGOS): \
138138
find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs sed -i -E "s%google.golang.org/grpc/codes%github.com/vdaas/vald/internal/net/grpc/codes%g"
139139
find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs sed -i -E "s%google.golang.org/grpc/status%github.com/vdaas/vald/internal/net/grpc/status%g"
140140
find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs sed -i -E "s%\"io\"%\"github.com/vdaas/vald/internal/io\"%g"
141+
find $(ROOTDIR)/apis/grpc/* -name '*.go' | xargs sed -i -E "s%\"sync\"%\"github.com/vdaas/vald/internal/sync\"%g"
141142

142143
$(SWAGGERS): \
143144
$(PROTOS) \

Makefile.d/test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ gotests/patch:
284284
@$(call green, "apply patches to go test files...")
285285
find $(ROOTDIR)/internal/k8s/* -name '*_test.go' | xargs sed -i -E "s%k8s.io/apimachinery/pkg/api/errors%github.com/vdaas/vald/internal/errors%g"
286286
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%cockroachdb/errors%vdaas/vald/internal/errors%g"
287-
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%golang.org/x/sync/errgroup%github.com/vdaas/vald/internal/errgroup%g"
287+
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%golang.org/x/sync/errgroup%github.com/vdaas/vald/internal/sync/errgroup%g"
288288
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%pkg/errors%vdaas/vald/internal/errors%g"
289289
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%go-errors/errors%vdaas/vald/internal/errors%g"
290290
find $(ROOTDIR)/* -name '*_test.go' | xargs sed -i -E "s%go.uber.org/goleak%github.com/vdaas/vald/internal/test/goleak%g"

apis/docs/v1/docs.md

Lines changed: 135 additions & 114 deletions
Large diffs are not rendered by default.

apis/grpc/v1/agent/core/agent.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/agent/sidecar/sidecar.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/discoverer/discoverer.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/filter/egress/egress_filter.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/filter/ingress/ingress_filter.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/manager/index/index_manager.pb.go

Lines changed: 29 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const _ = grpc.SupportPackageIsVersion7
4444
type IndexClient interface {
4545
// Represent the RPC to get the index information.
4646
IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error)
47+
// Represent the RPC to get the index information for each agents.
48+
IndexDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Detail, error)
4749
}
4850

4951
type indexClient struct {
@@ -63,12 +65,23 @@ func (c *indexClient) IndexInfo(ctx context.Context, in *payload.Empty, opts ...
6365
return out, nil
6466
}
6567

68+
func (c *indexClient) IndexDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Detail, error) {
69+
out := new(payload.Info_Index_Detail)
70+
err := c.cc.Invoke(ctx, "/manager.index.v1.Index/IndexDetail", in, out, opts...)
71+
if err != nil {
72+
return nil, err
73+
}
74+
return out, nil
75+
}
76+
6677
// IndexServer is the server API for Index service.
6778
// All implementations must embed UnimplementedIndexServer
6879
// for forward compatibility
6980
type IndexServer interface {
7081
// Represent the RPC to get the index information.
7182
IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error)
83+
// Represent the RPC to get the index information for each agents.
84+
IndexDetail(context.Context, *payload.Empty) (*payload.Info_Index_Detail, error)
7285
mustEmbedUnimplementedIndexServer()
7386
}
7487

@@ -79,6 +92,9 @@ type UnimplementedIndexServer struct {
7992
func (UnimplementedIndexServer) IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) {
8093
return nil, status.Errorf(codes.Unimplemented, "method IndexInfo not implemented")
8194
}
95+
func (UnimplementedIndexServer) IndexDetail(context.Context, *payload.Empty) (*payload.Info_Index_Detail, error) {
96+
return nil, status.Errorf(codes.Unimplemented, "method IndexDetail not implemented")
97+
}
8298
func (UnimplementedIndexServer) mustEmbedUnimplementedIndexServer() {}
8399

84100
// UnsafeIndexServer may be embedded to opt out of forward compatibility for this service.
@@ -110,6 +126,24 @@ func _Index_IndexInfo_Handler(srv interface{}, ctx context.Context, dec func(int
110126
return interceptor(ctx, in, info, handler)
111127
}
112128

129+
func _Index_IndexDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
130+
in := new(payload.Empty)
131+
if err := dec(in); err != nil {
132+
return nil, err
133+
}
134+
if interceptor == nil {
135+
return srv.(IndexServer).IndexDetail(ctx, in)
136+
}
137+
info := &grpc.UnaryServerInfo{
138+
Server: srv,
139+
FullMethod: "/manager.index.v1.Index/IndexDetail",
140+
}
141+
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
142+
return srv.(IndexServer).IndexDetail(ctx, req.(*payload.Empty))
143+
}
144+
return interceptor(ctx, in, info, handler)
145+
}
146+
113147
// Index_ServiceDesc is the grpc.ServiceDesc for Index service.
114148
// It's only intended for direct use with grpc.RegisterService,
115149
// and not to be introspected or modified (even as a copy)
@@ -121,6 +155,10 @@ var Index_ServiceDesc = grpc.ServiceDesc{
121155
MethodName: "IndexInfo",
122156
Handler: _Index_IndexInfo_Handler,
123157
},
158+
{
159+
MethodName: "IndexDetail",
160+
Handler: _Index_IndexDetail_Handler,
161+
},
124162
},
125163
Streams: []grpc.StreamDesc{},
126164
Metadata: "apis/proto/v1/manager/index/index_manager.proto",

0 commit comments

Comments
 (0)