-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementation for save index job (#2227)
* add index save implementation Signed-off-by: hlts2 <[email protected]> * make gotest/gen and make format Signed-off-by: hlts2 <[email protected]> * fix: sample configuration data Signed-off-by: hlts2 <[email protected]> * feat: add save indexing test Signed-off-by: hlts2 <[email protected]> * style: format code with Gofumpt and Prettier This commit fixes the style issues introduced in 84ade79 according to the output from Gofumpt and Prettier. Details: #2227 * fix: deleted unnecessary code Signed-off-by: hlts2 <[email protected]> * fix: update debug error message Signed-off-by: hlts2 <[email protected]> * fix: option name Signed-off-by: hlts2 <[email protected]> * fix: test case name Signed-off-by: hlts2 <[email protected]> * Update cmd/index/job/save/sample.yaml Co-authored-by: Kiichiro YUKAWA <[email protected]> * Update pkg/index/job/save/config/config.go Co-authored-by: Kiichiro YUKAWA <[email protected]> * fix: add comment for test case Signed-off-by: hlts2 <[email protected]> * fix: fix method naming Signed-off-by: hlts2 <[email protected]> * feat: add mock for discoverer client and grpc client Signed-off-by: hlts2 <[email protected]> * fix: struct tag for config Signed-off-by: hlts2 <[email protected]> * fix: cyclic import for testing Signed-off-by: hlts2 <[email protected]> --------- Signed-off-by: hlts2 <[email protected]> Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Kiichiro YUKAWA <[email protected]>
- Loading branch information
1 parent
cadd72e
commit c5cbfc9
Showing
19 changed files
with
2,237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# You may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
name: "Build docker image: index-save" | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*.*.*" | ||
- "v*.*.*" | ||
- "*.*.*-*" | ||
- "v*.*.*-*" | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/dockers-index-save.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/save/**" | ||
- "cmd/index/job/save/**" | ||
- "dockers/index/job/save/Dockerfile" | ||
- "versions/GO_VERSION" | ||
pull_request: | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/_docker-image.yaml" | ||
- ".github/workflows/dockers-index-save.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/save/**" | ||
- "cmd/index/job/save/**" | ||
- "dockers/index/job/save/Dockerfile" | ||
- "versions/GO_VERSION" | ||
pull_request_target: | ||
paths: | ||
- ".github/actions/docker-build/actions.yaml" | ||
- ".github/workflows/_docker-image.yaml" | ||
- ".github/workflows/dockers-index-save.yml" | ||
- "go.mod" | ||
- "go.sum" | ||
- "internal/**" | ||
- "!internal/**/*_test.go" | ||
- "!internal/db/**" | ||
- "!internal/k8s/**" | ||
- "apis/grpc/**" | ||
- "pkg/index/job/save/**" | ||
- "cmd/index/job/save/**" | ||
- "dockers/index/job/save/Dockerfile" | ||
- "versions/GO_VERSION" | ||
|
||
jobs: | ||
build: | ||
uses: ./.github/workflows/_docker-image.yaml | ||
with: | ||
target: index-save | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]> | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// You may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/vdaas/vald/internal/errors" | ||
"github.com/vdaas/vald/internal/info" | ||
"github.com/vdaas/vald/internal/log" | ||
"github.com/vdaas/vald/internal/runner" | ||
"github.com/vdaas/vald/internal/safety" | ||
"github.com/vdaas/vald/pkg/index/job/save/config" | ||
"github.com/vdaas/vald/pkg/index/job/save/usecase" | ||
) | ||
|
||
const ( | ||
maxVersion = "v0.0.10" | ||
minVersion = "v0.0.0" | ||
name = "index save job" | ||
) | ||
|
||
func main() { | ||
if err := safety.RecoverFunc(func() error { | ||
return runner.Do( | ||
context.Background(), | ||
runner.WithName(name), | ||
runner.WithVersion(info.Version, maxVersion, minVersion), | ||
runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) { | ||
cfg, err := config.NewConfig(path) | ||
if err != nil { | ||
return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration") | ||
} | ||
return cfg, &cfg.GlobalConfig, nil | ||
}), | ||
runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) { | ||
c, ok := cfg.(*config.Data) | ||
if !ok { | ||
return nil, errors.ErrInvalidConfig | ||
} | ||
return usecase.New(c) | ||
}), | ||
) | ||
})(); err != nil { | ||
log.Fatal(err, info.Get()) | ||
return | ||
} | ||
} |
Oops, something went wrong.