@@ -46,6 +46,7 @@ type options struct {
4646 pageSize int
4747 retryBackoff Backoff
4848 retryPredicate retry.Predicate
49+ retryStatusCodes []int
4950 filter map [string ]string
5051}
5152
@@ -83,7 +84,7 @@ var fastBackoff = Backoff{
8384 Steps : 3 ,
8485}
8586
86- var retryableStatusCodes = []int {
87+ var defaultRetryStatusCodes = []int {
8788 http .StatusRequestTimeout ,
8889 http .StatusInternalServerError ,
8990 http .StatusBadGateway ,
@@ -119,13 +120,14 @@ var DefaultTransport http.RoundTripper = &http.Transport{
119120
120121func makeOptions (opts ... Option ) (* options , error ) {
121122 o := & options {
122- transport : DefaultTransport ,
123- platform : defaultPlatform ,
124- context : context .Background (),
125- jobs : defaultJobs ,
126- pageSize : defaultPageSize ,
127- retryPredicate : defaultRetryPredicate ,
128- retryBackoff : defaultRetryBackoff ,
123+ transport : DefaultTransport ,
124+ platform : defaultPlatform ,
125+ context : context .Background (),
126+ jobs : defaultJobs ,
127+ pageSize : defaultPageSize ,
128+ retryPredicate : defaultRetryPredicate ,
129+ retryBackoff : defaultRetryBackoff ,
130+ retryStatusCodes : defaultRetryStatusCodes ,
129131 }
130132
131133 for _ , option := range opts {
@@ -154,7 +156,7 @@ func makeOptions(opts ...Option) (*options, error) {
154156 }
155157
156158 // Wrap the transport in something that can retry network flakes.
157- o .transport = transport .NewRetry (o .transport , transport .WithRetryPredicate (defaultRetryPredicate ), transport .WithRetryStatusCodes (retryableStatusCodes ... ))
159+ o .transport = transport .NewRetry (o .transport , transport .WithRetryPredicate (defaultRetryPredicate ), transport .WithRetryStatusCodes (o . retryStatusCodes ... ))
158160
159161 // Wrap this last to prevent transport.New from double-wrapping.
160162 if o .userAgent != "" {
@@ -303,6 +305,14 @@ func WithRetryPredicate(predicate retry.Predicate) Option {
303305 }
304306}
305307
308+ // WithRetryStatusCodes sets which http response codes will be retried.
309+ func WithRetryStatusCodes (codes ... int ) Option {
310+ return func (o * options ) error {
311+ o .retryStatusCodes = codes
312+ return nil
313+ }
314+ }
315+
306316// WithFilter sets the filter querystring for HTTP operations.
307317func WithFilter (key string , value string ) Option {
308318 return func (o * options ) error {
0 commit comments