Skip to content

Commit

Permalink
chore: rename cleanup to cleanupFn
Browse files Browse the repository at this point in the history
  • Loading branch information
batrov committed Dec 7, 2023
1 parent 8a01b7a commit cac5a26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/store/elasticsearch/discovery_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (repo *DiscoveryRepository) SyncAssets(ctx context.Context, indexName strin
return nil, err
}

cleanup := func() error {
cleanupFn := func() error {
err = repo.updateAlias(ctx, indexName, defaultSearchIndex)
if err != nil {
return err
Expand All @@ -117,7 +117,7 @@ func (repo *DiscoveryRepository) SyncAssets(ctx context.Context, indexName strin
return nil
}

return cleanup, err
return cleanupFn, err
}

func (repo *DiscoveryRepository) DeleteByID(ctx context.Context, assetID string) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/store/elasticsearch/discovery_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,14 @@ func TestDiscoveryRepository_SyncAssets(t *testing.T) {

repo := store.NewDiscoveryRepository(esClient, log.NewNoop(), time.Second*10, []string{"number", "id"})

cleanup, err := repo.SyncAssets(ctx, indexName)
cleanupFn, err := repo.SyncAssets(ctx, indexName)
require.NoError(t, err)

alias := cli.Indices.GetAlias
resp, _ := alias(alias.WithIndex(indexName))
require.NotEmpty(t, resp)

err = cleanup()
err = cleanupFn()
require.NoError(t, err)

res, err := cli.Indices.Exists([]string{"bigquery-test"})
Expand Down
6 changes: 3 additions & 3 deletions internal/workermanager/discovery_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type DiscoveryRepository interface {
Upsert(context.Context, asset.Asset) error
DeleteByURN(ctx context.Context, assetURN string) error
SyncAssets(ctx context.Context, indexName string) (cleanup func() error, err error)
SyncAssets(ctx context.Context, indexName string) (cleanupFn func() error, err error)
}

func (m *Manager) EnqueueIndexAssetJob(ctx context.Context, ast asset.Asset) error {
Expand Down Expand Up @@ -88,7 +88,7 @@ func (m *Manager) SyncAssets(ctx context.Context, job worker.JobSpec) error {
}
}

cleanup, err := m.discoveryRepo.SyncAssets(ctx, service)
cleanupFn, err := m.discoveryRepo.SyncAssets(ctx, service)
if err != nil {
return err
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func (m *Manager) SyncAssets(ctx context.Context, job worker.JobSpec) error {
it++
}

return cleanup()
return cleanupFn()
}

func (m *Manager) EnqueueDeleteAssetJob(ctx context.Context, urn string) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/workermanager/in_situ_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (m *InSituWorker) EnqueueSyncAssetJob(ctx context.Context, service string)
m.mutex.Lock()
defer m.mutex.Unlock()

cleanup, err := m.discoveryRepo.SyncAssets(ctx, service)
cleanupFn, err := m.discoveryRepo.SyncAssets(ctx, service)
if err != nil {
return err
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func (m *InSituWorker) EnqueueSyncAssetJob(ctx context.Context, service string)
it++
}

return cleanup()
return cleanupFn()
}

func (*InSituWorker) Close() error { return nil }

0 comments on commit cac5a26

Please sign in to comment.