Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Handle 408 Status Code as Retriable #263

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions client/api_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (a *AccountAPIService) AccountBalance(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -205,7 +206,8 @@ func (a *AccountAPIService) AccountCoins(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
6 changes: 4 additions & 2 deletions client/api_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func (a *BlockAPIService) Block(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -205,7 +206,8 @@ func (a *BlockAPIService) BlockTransaction(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
3 changes: 2 additions & 1 deletion client/api_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func (a *CallAPIService) Call(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
24 changes: 16 additions & 8 deletions client/api_construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ func (a *ConstructionAPIService) ConstructionCombine(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -188,7 +189,8 @@ func (a *ConstructionAPIService) ConstructionDerive(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -273,7 +275,8 @@ func (a *ConstructionAPIService) ConstructionHash(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -365,7 +368,8 @@ func (a *ConstructionAPIService) ConstructionMetadata(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -451,7 +455,8 @@ func (a *ConstructionAPIService) ConstructionParse(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -542,7 +547,8 @@ func (a *ConstructionAPIService) ConstructionPayloads(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -631,7 +637,8 @@ func (a *ConstructionAPIService) ConstructionPreprocess(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -719,7 +726,8 @@ func (a *ConstructionAPIService) ConstructionSubmit(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
3 changes: 2 additions & 1 deletion client/api_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func (a *EventsAPIService) EventsBlocks(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
6 changes: 4 additions & 2 deletions client/api_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ func (a *MempoolAPIService) Mempool(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -191,7 +192,8 @@ func (a *MempoolAPIService) MempoolTransaction(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
9 changes: 6 additions & 3 deletions client/api_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ func (a *NetworkAPIService) NetworkList(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -188,7 +189,8 @@ func (a *NetworkAPIService) NetworkOptions(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down Expand Up @@ -273,7 +275,8 @@ func (a *NetworkAPIService) NetworkStatus(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
3 changes: 2 additions & 1 deletion client/api_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func (a *SearchAPIService) SearchTransactions(
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down
3 changes: 2 additions & 1 deletion templates/client/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx _context.Context{{#hasParams
return nil, &v, fmt.Errorf("%+v", v)
case _nethttp.StatusBadGateway,
_nethttp.StatusServiceUnavailable,
_nethttp.StatusGatewayTimeout:
_nethttp.StatusGatewayTimeout,
_nethttp.StatusRequestTimeout:
return nil, nil, fmt.Errorf(
"%w: code: %d body: %s",
ErrRetriable,
Expand Down