Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumeet Rai committed Sep 27, 2024
1 parent 6df32ee commit ceebdd9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions core/asset/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Service struct {
worker Worker
logger log.Logger
config Config
cancelFnMap sync.Map
cancelFnMap *sync.Map
assetOpCounter metric.Int64Counter
}

Expand Down Expand Up @@ -58,7 +58,7 @@ func NewService(deps ServiceDeps) (service *Service, cancel func()) {
worker: deps.Worker,
logger: deps.Logger,
config: deps.Config,
cancelFnMap: sync.Map{},
cancelFnMap: new(sync.Map),
assetOpCounter: assetOpCounter,
}

Expand Down Expand Up @@ -156,7 +156,7 @@ func (s *Service) DeleteAssets(ctx context.Context, request DeleteAssetsRequest)

if !request.DryRun && total > 0 {
newCtx, cancel := context.WithTimeout(context.Background(), s.config.DeleteAssetsTimeout)
cancelID := generateUniqueCancelID()
cancelID := uuid.New().String()
s.cancelFnMap.Store(cancelID, cancel)
go func(id string) {
s.executeDeleteAssets(newCtx, deleteSQLExpr)
Expand All @@ -168,10 +168,6 @@ func (s *Service) DeleteAssets(ctx context.Context, request DeleteAssetsRequest)
return uint32(total), nil
}

func generateUniqueCancelID() string {
return uuid.New().String()
}

func (s *Service) executeDeleteAssets(ctx context.Context, deleteSQLExpr queryexpr.ExprStr) {
deletedURNs, err := s.assetRepository.DeleteByQueryExpr(ctx, deleteSQLExpr)
if err != nil {
Expand Down

0 comments on commit ceebdd9

Please sign in to comment.