Repository: go-to-k/delstack
Pull request #117 (2023-03-05 09:58:47)

Chore/change retry


Patch:
diff --git a/pkg/client/waiter.go b/pkg/client/retryer.go
similarity index 92%
rename from pkg/client/waiter.go
rename to pkg/client/retryer.go
index 190bbcb..d3b6f2b 100644
--- a/pkg/client/waiter.go
+++ b/pkg/client/retryer.go
@@ -12,7 +12,7 @@ const MaxRetryCount = 10
 
 // T: Input type for API Request.
 // U: Output type for API Response.
-// V: Option Functions type for API Request.
+// V: Options type for API Request.
 type RetryInput[T, U, V any] struct {
 	Ctx              context.Context
 	SleepTimeSec     int
@@ -25,7 +25,7 @@ type RetryInput[T, U, V any] struct {
 
 // T: Input type for API Request.
 // U: Output type for API Response.
-// V: Option Functions type for API Request.
+// V: Options type for API Request.
 func Retry[T, U, V any](
 	in *RetryInput[T, U, V],
 ) (*U, error) {
@@ -50,7 +50,7 @@ func Retry[T, U, V any](
 
 func waitForRetry(ctx context.Context, retryCount int, sleepTimeSec int, targetResource *string, err error) error {
 	if retryCount > MaxRetryCount {
-		errorDetail := err.Error() + "\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "
+		errorDetail := err.Error() + "\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "
 		return fmt.Errorf("RetryCountOverError: %v, %v", *targetResource, errorDetail)
 	}
 


Test patch:
diff --git a/pkg/client/iam_test.go b/pkg/client/iam_test.go
index 98e3ab6..a873be4 100644
--- a/pkg/client/iam_test.go
+++ b/pkg/client/iam_test.go
@@ -109,7 +109,7 @@ func TestIam_DeleteRole(t *testing.T) {
 					)
 				},
 			},
-			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DeleteRole, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DeleteRole, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			wantErr: true,
 		},
 	}
@@ -277,7 +277,7 @@ func TestIam_ListAttachedRolePolicies(t *testing.T) {
 			},
 			want: want{
 				output: nil,
-				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: ListAttachedRolePolicies, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: ListAttachedRolePolicies, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			},
 			wantErr: true,
 		},
@@ -487,7 +487,7 @@ func TestIam_ListAttachedRolePolicies(t *testing.T) {
 			},
 			want: want{
 				output: nil,
-				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: ListAttachedRolePolicies, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: ListAttachedRolePolicies, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			},
 			wantErr: true,
 		},
@@ -654,7 +654,7 @@ func TestIam_DetachRolePolicies(t *testing.T) {
 					)
 				},
 			},
-			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DetachRolePolicy, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DetachRolePolicy, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			wantErr: true,
 		},
 	}
@@ -766,7 +766,7 @@ func TestIam_DetachRolePolicy(t *testing.T) {
 					)
 				},
 			},
-			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DetachRolePolicy, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+			want:    fmt.Errorf("RetryCountOverError: test, operation error IAM: DetachRolePolicy, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			wantErr: true,
 		},
 	}
@@ -916,7 +916,7 @@ func TestIam_CheckRoleExists(t *testing.T) {
 			},
 			want: want{
 				exists: false,
-				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: GetRole, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+				err:    fmt.Errorf("RetryCountOverError: test, operation error IAM: GetRole, api error Throttling: Rate exceeded\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			},
 			wantErr: true,
 		},
diff --git a/pkg/client/waiter_test.go b/pkg/client/retryer_test.go
similarity index 99%
rename from pkg/client/waiter_test.go
rename to pkg/client/retryer_test.go
index a83c3b9..51d77b0 100644
--- a/pkg/client/waiter_test.go
+++ b/pkg/client/retryer_test.go
@@ -34,7 +34,7 @@ func TestRetry(t *testing.T) {
 					return true
 				},
 			},
-			want:    fmt.Errorf("RetryCountOverError: resource, ApiFuncError\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+			want:    fmt.Errorf("RetryCountOverError: resource, ApiFuncError\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			wantErr: true,
 		},
 		{
@@ -215,7 +215,7 @@ func Test_waitForRetry(t *testing.T) {
 				targetResourceType: aws.String("resource"),
 				err:                fmt.Errorf("API Error"),
 			},
-			want:    fmt.Errorf("RetryCountOverError: resource, API Error\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+			want:    fmt.Errorf("RetryCountOverError: resource, API Error\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			wantErr: true,
 		},
 	}
diff --git a/pkg/client/s3_test.go b/pkg/client/s3_test.go
index f1bdeea..8f126fb 100644
--- a/pkg/client/s3_test.go
+++ b/pkg/client/s3_test.go
@@ -305,7 +305,7 @@ func TestS3_DeleteObjects(t *testing.T) {
 			},
 			want: want{
 				output: nil,
-				err:    fmt.Errorf("RetryCountOverError: test, operation error S3: DeleteObjects, api error SlowDown\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed to delete. "),
+				err:    fmt.Errorf("RetryCountOverError: test, operation error S3: DeleteObjects, api error SlowDown\nRetryCount(" + strconv.Itoa(MaxRetryCount) + ") over, but failed. "),
 			},
 			wantErr: true,
 		},