generated from PenaSide/GolangTemplate
safe append
This commit is contained in:
parent
a32f4d5efd
commit
13c955d65f
@ -404,6 +404,7 @@ func (api *API2) PayCart(ctx echo.Context) error {
|
||||
|
||||
sendErrors := make([]errors.Error, 0)
|
||||
waitGroup := sync.WaitGroup{}
|
||||
mutex := sync.Mutex{}
|
||||
|
||||
for _, tariff := range tariffs {
|
||||
waitGroup.Add(1)
|
||||
@ -413,6 +414,8 @@ func (api *API2) PayCart(ctx echo.Context) error {
|
||||
|
||||
if err := api.producer.Send(ctx.Request().Context(), userID, ¤tTariff); err != nil {
|
||||
api.logger.Error("failed to send tariff on <Send> of <TariffBrokerService>", zap.Error(err))
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
sendErrors = append(sendErrors, err)
|
||||
}
|
||||
}(tariff)
|
||||
|
Loading…
Reference in New Issue
Block a user