Drop link self-healing paths, fix linter findings
- Remove link resync on module reconnect, link resave on no-op config update, and link backfill on variable create/upsert: links are formed only on config save - Disable exhaustruct_v5 and goconst linters - Fix golangci-lint findings: noinlineerr, slices.Backward, wrapcheck for ConfigValidationError (errors.As in controller keeps working via %w), funlen nolint on acceptance test
This commit is contained in:
1 parent
7f4e3ef028
commit
c464393e93
9 files changed
+9
-114
No files matched your search
@@ -20,12 +20,10 @@ type Repo interface {
|
||||
Upsert(ctx context.Context, variables []entity.Variable) error
|
||||
Delete(ctx context.Context, name string) (bool, error)
|
||||
UpsertLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error
|
||||
InsertLinks(ctx context.Context, links []entity.ConfigHasVariable) error
|
||||
}
|
||||
|
||||
type ConfigRepo interface {
|
||||
GetMetaByVariables(ctx context.Context, variables []string) (map[string][]entity.ConfigMetaWithVariable, error)
|
||||
FindIdsByVariableReference(ctx context.Context, variableName string) ([]string, error)
|
||||
}
|
||||
|
||||
type EventRepo interface {
|
||||
@@ -108,16 +106,6 @@ func (s Service) Create(ctx context.Context, req domain.CreateVariableRequest) e
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "insert variable")
|
||||
}
|
||||
|
||||
err = s.syncVariableLinks(ctx, []string{variable.Name})
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "sync variable links")
|
||||
}
|
||||
|
||||
err = s.syncConfigsByVariables(ctx, []string{variable.Name})
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "sync configs by variables")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -163,11 +151,6 @@ func (s Service) Upsert(ctx context.Context, req []domain.UpsertVariableRequest)
|
||||
return errors.WithMessage(err, "upsert variables")
|
||||
}
|
||||
|
||||
err = s.syncVariableLinks(ctx, variableNames)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "sync variable links")
|
||||
}
|
||||
|
||||
err = s.syncConfigsByVariables(ctx, variableNames)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "sync configs by variables")
|
||||
@@ -310,28 +293,6 @@ func (s Service) toDto(variable entity.Variable, metaByVariables map[string][]en
|
||||
}
|
||||
}
|
||||
|
||||
func (s Service) syncVariableLinks(ctx context.Context, variableNames []string) error {
|
||||
for _, name := range variableNames {
|
||||
configIds, err := s.configRepo.FindIdsByVariableReference(ctx, name)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "find configs referencing variable: %s", name)
|
||||
}
|
||||
links := make([]entity.ConfigHasVariable, 0, len(configIds))
|
||||
for _, configId := range configIds {
|
||||
links = append(links, entity.ConfigHasVariable{
|
||||
ConfigId: configId,
|
||||
VariableName: name,
|
||||
})
|
||||
}
|
||||
err = s.repo.InsertLinks(ctx, links)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "insert links for variable: %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s Service) syncConfigsByVariables(ctx context.Context, variables []string) error {
|
||||
metaByVariables, err := s.configRepo.GetMetaByVariables(ctx, variables)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user