Skip to content

Commit

Permalink
fix: reviewdog warning and rename config file
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Oct 31, 2023
1 parent 381b0b7 commit ac9c364
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.
package config

// IndexCreator represents the index creator configurations.
type IndexCreator struct {
// IndexCreation represents the configurations for index creation.
type IndexCreation struct {
// AgentPort represent agent port number
AgentPort int `json:"agent_port" yaml:"agent_port"`

Expand All @@ -34,16 +34,16 @@ type IndexCreator struct {
Concurrency int `json:"concurrency" yaml:"concurrency"`

// CreationPoolSize represents batch pool size for indexing.
CreationPoolSize uint32 `yaml:"creation_pool_size" json:"creation_pool_size"`
CreationPoolSize uint32 `json:"creation_pool_size" yaml:"creation_pool_size"`

// TargetAddrs represents indexing target addresses.
TargetAddrs []string `yaml:"target_addrs" json:"target_addrs"`
TargetAddrs []string `json:"target_addrs" yaml:"target_addrs"`

// Discoverer represents agent discoverer service configuration.
Discoverer *DiscovererClient `json:"discoverer" yaml:"discoverer"`
}

func (ic *IndexCreator) Bind() *IndexCreator {
func (ic *IndexCreation) Bind() *IndexCreation {
ic.AgentName = GetActualValue(ic.AgentName)
ic.AgentNamespace = GetActualValue(ic.AgentNamespace)
ic.AgentDNS = GetActualValue(ic.AgentDNS)
Expand Down
8 changes: 4 additions & 4 deletions pkg/index/job/creation/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type Data struct {
// Observability represents observability configurations.
Observability *config.Observability `json:"observability" yaml:"observability"`

// Creator represents auto indexing service configurations.
Creator *config.IndexCreator `json:"creator" yaml:"creator"`
// Creation represents auto indexing service configurations.
Creation *config.IndexCreation `json:"creator" yaml:"creator"`
}

// NewConfig load configurations from file path.
Expand Down Expand Up @@ -62,8 +62,8 @@ func NewConfig(path string) (cfg *Data, err error) {
cfg.Observability = new(config.Observability).Bind()
}

if cfg.Creator != nil {
_ = cfg.Creator.Bind()
if cfg.Creation != nil {
_ = cfg.Creation.Bind()
} else {
return nil, errors.ErrInvalidConfig
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/index/job/creation/service/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package service
import (
"context"
"reflect"
"sync"

agent "github.com/vdaas/vald/apis/grpc/v1/agent/core"
"github.com/vdaas/vald/apis/grpc/v1/payload"
Expand All @@ -27,6 +26,7 @@ import (
"github.com/vdaas/vald/internal/net/grpc/codes"
"github.com/vdaas/vald/internal/net/grpc/status"
"github.com/vdaas/vald/internal/observability/trace"
"github.com/vdaas/vald/internal/sync"
)

const (
Expand Down
22 changes: 11 additions & 11 deletions pkg/index/job/creation/usecase/creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ type run struct {
func New(cfg *config.Data) (_ runner.Runner, err error) {
eg := errgroup.Get()

dOpts, err := cfg.Creator.Discoverer.Client.Opts()
dOpts, err := cfg.Creation.Discoverer.Client.Opts()
if err != nil {
return nil, err
}
// skipcq: CRT-D0001
dOpts = append(dOpts, grpc.WithErrGroup(eg))

acOpts, err := cfg.Creator.Discoverer.AgentClientOptions.Opts()
acOpts, err := cfg.Creation.Discoverer.AgentClientOptions.Opts()
if err != nil {
return nil, err
}
Expand All @@ -62,14 +62,14 @@ func New(cfg *config.Data) (_ runner.Runner, err error) {

discoverer, err := discoverer.New(
discoverer.WithAutoConnect(true),
discoverer.WithName(cfg.Creator.AgentName),
discoverer.WithNamespace(cfg.Creator.AgentNamespace),
discoverer.WithPort(cfg.Creator.AgentPort),
discoverer.WithServiceDNSARecord(cfg.Creator.AgentDNS),
discoverer.WithName(cfg.Creation.AgentName),
discoverer.WithNamespace(cfg.Creation.AgentNamespace),
discoverer.WithPort(cfg.Creation.AgentPort),
discoverer.WithServiceDNSARecord(cfg.Creation.AgentDNS),
discoverer.WithDiscovererClient(grpc.New(dOpts...)),
discoverer.WithDiscoverDuration(cfg.Creator.Discoverer.Duration),
discoverer.WithDiscoverDuration(cfg.Creation.Discoverer.Duration),
discoverer.WithOptions(acOpts...),
discoverer.WithNodeName(cfg.Creator.NodeName),
discoverer.WithNodeName(cfg.Creation.NodeName),
discoverer.WithOnDiscoverFunc(func(ctx context.Context, c discoverer.Client, addrs []string) error {
last := len(addrs) - 1
for i := 0; i < len(addrs)/2; i++ {
Expand All @@ -84,9 +84,9 @@ func New(cfg *config.Data) (_ runner.Runner, err error) {

indexer, err := service.New(
service.WithDiscoverer(discoverer),
service.WithIndexingConcurrency(cfg.Creator.Concurrency),
service.WithCreationPoolSize(cfg.Creator.CreationPoolSize),
service.WithTargetAddrs(cfg.Creator.TargetAddrs...),
service.WithIndexingConcurrency(cfg.Creation.Concurrency),
service.WithCreationPoolSize(cfg.Creation.CreationPoolSize),
service.WithTargetAddrs(cfg.Creation.TargetAddrs...),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit ac9c364

Please sign in to comment.