Skip to content

Commit

Permalink
don't wait 5 seconds on for each lambda update
Browse files Browse the repository at this point in the history
  • Loading branch information
ianic committed Dec 25, 2021
1 parent 590bf6c commit cf9791d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions aws/lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/lambda"
lambdaTypes "github.com/aws/aws-sdk-go-v2/service/lambda/types"
"github.com/mantil-io/mantil/cli/log"
)

func (a *AWS) LambdaExists(name string) (bool, error) {
Expand Down Expand Up @@ -179,9 +180,16 @@ func (a *AWS) WaitLambdaFunctionUpdated(function string) error {
FunctionName: aws.String(function),
}

retryInterval := 5 * time.Second
retryInterval := 100 * time.Millisecond
retryAttempts := 60
for retryAttempts > 0 {
log.Printf("wait for lambda function attemptd: %d, interval: %d", retryAttempts, retryInterval)

time.Sleep(retryInterval)
retryAttempts--
if retryAttempts < 50 && retryInterval < time.Second {
retryInterval = retryInterval * 2
}
gfco, err := a.lambdaClient.GetFunctionConfiguration(context.Background(), gfci)
if err != nil {
return err
Expand All @@ -192,8 +200,7 @@ func (a *AWS) WaitLambdaFunctionUpdated(function string) error {
if gfco.LastUpdateStatus == lambdaTypes.LastUpdateStatusFailed {
return errors.New(*gfco.LastUpdateStatusReason)
}
time.Sleep(retryInterval)
retryAttempts--

}
return nil
}
Expand Down

0 comments on commit cf9791d

Please sign in to comment.