@@ -22,19 +22,24 @@ const (
22
22
)
23
23
24
24
func (s * EdgeRuntimeAPI ) UpsertFunctions (ctx context.Context , functionConfig config.FunctionConfig , filter ... func (string ) bool ) error {
25
- var result []api.FunctionResponse
26
- if resp , err := s .client .V1ListAllFunctionsWithResponse (ctx , s .project ); err != nil {
27
- return errors .Errorf ("failed to list functions: %w" , err )
28
- } else if resp .JSON200 == nil {
29
- return errors .Errorf ("unexpected list functions status %d: %s" , resp .StatusCode (), string (resp .Body ))
30
- } else {
31
- result = * resp .JSON200
25
+ policy := backoff .WithContext (backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ), ctx )
26
+ result , err := backoff .RetryWithData (func () ([]api.FunctionResponse , error ) {
27
+ resp , err := s .client .V1ListAllFunctionsWithResponse (ctx , s .project )
28
+ if err != nil {
29
+ return nil , errors .Errorf ("failed to list functions: %w" , err )
30
+ } else if resp .JSON200 == nil {
31
+ return nil , errors .Errorf ("unexpected list functions status %d: %s" , resp .StatusCode (), string (resp .Body ))
32
+ }
33
+ return * resp .JSON200 , nil
34
+ }, policy )
35
+ if err != nil {
36
+ return err
32
37
}
38
+ policy .Reset ()
33
39
exists := make (map [string ]struct {}, len (result ))
34
40
for _ , f := range result {
35
41
exists [f .Slug ] = struct {}{}
36
42
}
37
- policy := backoff .WithContext (backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ), ctx )
38
43
var toUpdate []api.BulkUpdateFunctionBody
39
44
OUTER:
40
45
for slug , function := range functionConfig {
0 commit comments