Skip to content

Commit

Permalink
feat: log malformed data during upsert ES docs
Browse files Browse the repository at this point in the history
  • Loading branch information
batrov committed Jan 4, 2024
1 parent 39a1cee commit 6bab8f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/workermanager/discovery_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"time"

"github.com/goto/compass/core/asset"
Expand Down Expand Up @@ -108,6 +109,10 @@ func (m *Manager) SyncAssets(ctx context.Context, job worker.JobSpec) error {

for _, ast := range assets {
if err := m.discoveryRepo.Upsert(ctx, ast); err != nil {
if strings.Contains(err.Error(), "illegal_argument_exception") {
m.logger.Error(err.Error())
continue
}
return err
}
}
Expand Down
9 changes: 9 additions & 0 deletions internal/workermanager/in_situ_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ package workermanager
import (
"context"
"fmt"
"strings"
"sync"

"github.com/goto/salt/log"

Check failure on line 9 in internal/workermanager/in_situ_worker.go

View workflow job for this annotation

GitHub Actions / golangci

File is not `gci`-ed with --skip-generated -s standard -s default (gci)

"github.com/goto/compass/core/asset"
)

type InSituWorker struct {
discoveryRepo DiscoveryRepository
assetRepo asset.Repository
mutex sync.Mutex
logger log.Logger
}

func NewInSituWorker(deps Deps) *InSituWorker {
return &InSituWorker{
discoveryRepo: deps.DiscoveryRepo,
assetRepo: deps.AssetRepo,
logger: deps.Logger,
}
}

Expand Down Expand Up @@ -61,6 +66,10 @@ func (m *InSituWorker) EnqueueSyncAssetJob(ctx context.Context, service string)

for _, ast := range assets {
if err := m.discoveryRepo.Upsert(ctx, ast); err != nil {
if strings.Contains(err.Error(), "illegal_argument_exception") {
m.logger.Error(err.Error())
continue
}
return err
}
}
Expand Down

0 comments on commit 6bab8f3

Please sign in to comment.