Skip to content

Commit

Permalink
Merge pull request #1671 from anyproto/go-4243-app-close-many-spaces
Browse files Browse the repository at this point in the history
GO-4243 app close many spaces
  • Loading branch information
requilence authored Oct 14, 2024
2 parents 8418e48 + c9897e8 commit e33a1e2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions space/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,18 @@ func (s *service) Close(ctx context.Context) error {
}
s.mu.Unlock()

wg := sync.WaitGroup{}
for _, ctrl := range ctrls {
err := ctrl.Close(ctx)
if err != nil {
log.Error("close space", zap.String("spaceId", ctrl.SpaceId()), zap.Error(err))
}
wg.Add(1)
go func(ctrl spacecontroller.SpaceController) {
defer wg.Done()
err := ctrl.Close(ctx)
if err != nil {
log.Error("close space", zap.String("spaceId", ctrl.SpaceId()), zap.Error(err))
}
}(ctrl)
}
wg.Wait()
err := s.techSpace.Close(ctx)
if err != nil {
log.Error("close tech space", zap.Error(err))
Expand Down

0 comments on commit e33a1e2

Please sign in to comment.