MCPcopy Create free account
hub / github.com/apache/cloudstack-terraform-provider / Retry

Function Retry

cloudstack/resources.go:130–144  ·  view source on GitHub ↗

Retry is a wrapper around a RetryFunc that will retry a function n times or until it succeeds.

(n int, f RetryFunc)

Source from the content-addressed store, hash-verified

128// Retry is a wrapper around a RetryFunc that will retry a function
129// n times or until it succeeds.
130func Retry(n int, f RetryFunc) (interface{}, error) {
131 var lastErr error
132
133 for i := 0; i < n; i++ {
134 r, err := f()
135 if err == nil || err == cloudstack.AsyncTimeoutErr {
136 return r, err
137 }
138
139 lastErr = err
140 time.Sleep(30 * time.Second)
141 }
142
143 return nil, lastErr
144}
145
146// If there is a project supplied, we retrieve and set the project id
147func setProjectid(p cloudstack.ProjectIDSetter, cs *cloudstack.CloudStackClient, d *schema.ResourceData) error {

Callers 4

createNetworkACLRuleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected