github.com/sap/cf-mta-plugin@v2.6.3+incompatible/clients/restclient/retryable_rest_client.go (about) 1 package restclient 2 3 import ( 4 "net/http" 5 "time" 6 7 baseclient "github.com/cloudfoundry-incubator/multiapps-cli-plugin/clients/baseclient" 8 ) 9 10 // RetryableRestClient represents retryable REST client for the MTA deployer REST protocol 11 type RetryableRestClient struct { 12 RestClient RestClientOperations 13 MaxRetriesCount int 14 RetryInterval time.Duration 15 } 16 17 // NewRetryableRestClient creates a new retryable REST client 18 func NewRetryableRestClient(host string, rt http.RoundTripper, tokenFactory baseclient.TokenFactory) RestClientOperations { 19 restClient := NewRestClient(host, rt, tokenFactory) 20 return RetryableRestClient{restClient, 3, time.Second * 3} 21 } 22 23 // PurgeConfiguration purges a configuration 24 func (c RetryableRestClient) PurgeConfiguration(org, space string) error { 25 purgeConfigurationCb := func() (interface{}, error) { 26 return nil, c.RestClient.PurgeConfiguration(org, space) 27 } 28 _, err := baseclient.CallWithRetry(purgeConfigurationCb, c.MaxRetriesCount, c.RetryInterval) 29 return err 30 }