Skip to content

Commit

Permalink
refactor index manager service
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed May 14, 2024
1 parent 6d4b505 commit 189ec53
Show file tree
Hide file tree
Showing 48 changed files with 1,502 additions and 467 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ assignees: ""
- Rust Version: 1.77.2
- Docker Version: 20.10.8
- Kubernetes Version: v1.30.0
- NGT Version: 2.2.1
- NGT Version: 2.2.2
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/security_issue_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ assignees: ""
- Rust Version: 1.77.2
- Docker Version: 20.10.8
- Kubernetes Version: v1.30.0
- NGT Version: 2.2.1
- NGT Version: 2.2.2
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- Rust Version: 1.77.2
- Docker Version: 20.10.8
- Kubernetes Version: v1.30.0
- NGT Version: 2.2.1
- NGT Version: 2.2.2

### Checklist

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
git push origin ${VERSION}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
with:
Expand Down
3 changes: 2 additions & 1 deletion Makefile.d/dependencies.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ go/download:

.PHONY: go/deps
## install Go package dependencies
go/deps:
go/deps: \
update/go
sed -i "3s/go [0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/go $(GO_VERSION)/g" $(ROOTDIR)/hack/go.mod.default
if $(GO_CLEAN_DEPS); then \
rm -rf $(ROOTDIR)/vendor \
Expand Down
4 changes: 1 addition & 3 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,12 @@ define gen-vald-crd
endef

define update-github-actions
@for ACTION_NAME in $1; do \
@set -e; for ACTION_NAME in $1; do \
if [ -n "$$ACTION_NAME" ] && [ "$$ACTION_NAME" != "security-and-quality" ]; then \
FILE_NAME=`echo $$ACTION_NAME | tr '/' '_' | tr '-' '_' | tr '[:lower:]' '[:upper:]'`; \
if [ -n "$$FILE_NAME" ]; then \
if [ "$$ACTION_NAME" = "aquasecurity/trivy-action" ] || [ "$$ACTION_NAME" = "machine-learning-apps/actions-chatops" ]; then \
VERSION="master"; \
elif [ "$$ACTION_NAME" = "softprops/action-gh-release" ]; then \
VERSION="1.0.0"; \
else \
REPO_NAME=`echo $$ACTION_NAME | cut -d'/' -f1-2`; \
VERSION=`curl -fsSL https://api.github.com/repos/$$REPO_NAME/releases/latest | grep -Po '"tag_name": "\K.*?(?=")' | sed 's/v//g' | sed -E 's/[^0-9.]+//g'`;\
Expand Down
30 changes: 27 additions & 3 deletions apis/docs/v1/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
- [Info.IPs](#payload-v1-Info-IPs)
- [Info.Index](#payload-v1-Info-Index)
- [Info.Index.Count](#payload-v1-Info-Index-Count)
- [Info.Index.Detail](#payload-v1-Info-Index-Detail)
- [Info.Index.Detail.CountsEntry](#payload-v1-Info-Index-Detail-CountsEntry)
- [Info.Index.UUID](#payload-v1-Info-Index-UUID)
- [Info.Index.UUID.Committed](#payload-v1-Info-Index-UUID-Committed)
- [Info.Index.UUID.Uncommitted](#payload-v1-Info-Index-UUID-Uncommitted)
Expand Down Expand Up @@ -294,6 +296,27 @@ Represent the index count message.
| indexing | [bool](#bool) | | The indexing index count. |
| saving | [bool](#bool) | | The saving index count. |

<a name="payload-v1-Info-Index-Detail"></a>

### Info.Index.Detail

Represent the index count for each Agents message.

| Field | Type | Label | Description |
| ----------- | -------------------------------------------------------------------------- | -------- | ---------------------------------- |
| counts | [Info.Index.Detail.CountsEntry](#payload-v1-Info-Index-Detail-CountsEntry) | repeated | count infos for each agents |
| replica | [uint32](#uint32) | | index replica of vald cluster |
| live_agents | [uint32](#uint32) | | live agent replica of vald cluster |

<a name="payload-v1-Info-Index-Detail-CountsEntry"></a>

### Info.Index.Detail.CountsEntry

| Field | Type | Label | Description |
| ----- | ------------------------------------------------ | ----- | ----------- |
| key | [string](#string) | | |
| value | [Info.Index.Count](#payload-v1-Info-Index-Count) | | |

<a name="payload-v1-Info-Index-UUID"></a>

### Info.Index.UUID
Expand Down Expand Up @@ -1156,9 +1179,10 @@ Represent the ingress filter service.

Represent the index manager service.

| Method Name | Request Type | Response Type | Description |
| ----------- | -------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- |
| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. |
| Method Name | Request Type | Response Type | Description |
| ----------- | -------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------- |
| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. |
| IndexDetail | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Detail](#payload-v1-Info-Index-Detail) | Represent the RPC to get the index information for each agents. |

<a name="v1_mirror_mirror-proto"></a>

Expand Down
46 changes: 27 additions & 19 deletions apis/grpc/v1/manager/index/index_manager.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions apis/grpc/v1/manager/index/index_manager_vtproto.pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const _ = grpc.SupportPackageIsVersion7
type IndexClient interface {
// Represent the RPC to get the index information.
IndexInfo(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Count, error)
// Represent the RPC to get the index information for each agents.
IndexDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Detail, error)
}

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

func (c *indexClient) IndexDetail(ctx context.Context, in *payload.Empty, opts ...grpc.CallOption) (*payload.Info_Index_Detail, error) {
out := new(payload.Info_Index_Detail)
err := c.cc.Invoke(ctx, "/manager.index.v1.Index/IndexDetail", in, out, opts...)
if err != nil {
return nil, err

Check warning on line 72 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L68-L72

Added lines #L68 - L72 were not covered by tests
}
return out, nil

Check warning on line 74 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

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

Added line #L74 was not covered by tests
}

// IndexServer is the server API for Index service.
// All implementations must embed UnimplementedIndexServer
// for forward compatibility
type IndexServer interface {
// Represent the RPC to get the index information.
IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error)
// Represent the RPC to get the index information for each agents.
IndexDetail(context.Context, *payload.Empty) (*payload.Info_Index_Detail, error)
mustEmbedUnimplementedIndexServer()
}

Expand All @@ -79,6 +92,9 @@ type UnimplementedIndexServer struct {
func (UnimplementedIndexServer) IndexInfo(context.Context, *payload.Empty) (*payload.Info_Index_Count, error) {
return nil, status.Errorf(codes.Unimplemented, "method IndexInfo not implemented")
}
func (UnimplementedIndexServer) IndexDetail(context.Context, *payload.Empty) (*payload.Info_Index_Detail, error) {
return nil, status.Errorf(codes.Unimplemented, "method IndexDetail not implemented")

Check warning on line 96 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L95-L96

Added lines #L95 - L96 were not covered by tests
}
func (UnimplementedIndexServer) mustEmbedUnimplementedIndexServer() {}

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

func _Index_IndexDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(payload.Empty)
if err := dec(in); err != nil {
return nil, err

Check warning on line 132 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L129-L132

Added lines #L129 - L132 were not covered by tests
}
if interceptor == nil {
return srv.(IndexServer).IndexDetail(ctx, in)

Check warning on line 135 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L134-L135

Added lines #L134 - L135 were not covered by tests
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/manager.index.v1.Index/IndexDetail",

Check warning on line 139 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L137-L139

Added lines #L137 - L139 were not covered by tests
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IndexServer).IndexDetail(ctx, req.(*payload.Empty))

Check warning on line 142 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

apis/grpc/v1/manager/index/index_manager_vtproto.pb.go#L141-L142

Added lines #L141 - L142 were not covered by tests
}
return interceptor(ctx, in, info, handler)

Check warning on line 144 in apis/grpc/v1/manager/index/index_manager_vtproto.pb.go

View check run for this annotation

Codecov / codecov/patch

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

Added line #L144 was not covered by tests
}

// Index_ServiceDesc is the grpc.ServiceDesc for Index service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
Expand All @@ -121,6 +155,10 @@ var Index_ServiceDesc = grpc.ServiceDesc{
MethodName: "IndexInfo",
Handler: _Index_IndexInfo_Handler,
},
{
MethodName: "IndexDetail",
Handler: _Index_IndexDetail_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "v1/manager/index/index_manager.proto",
Expand Down
Loading

0 comments on commit 189ec53

Please sign in to comment.