mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Removing AppError check from the retry layer (#16307)
This commit is contained in:
@@ -20,16 +20,11 @@ import (
|
||||
|
||||
const (
|
||||
OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
|
||||
APP_ERROR_TYPE = "*model.AppError"
|
||||
ERROR_TYPE = "error"
|
||||
)
|
||||
|
||||
func isError(typeName string) bool {
|
||||
return strings.Contains(typeName, APP_ERROR_TYPE) || strings.Contains(typeName, ERROR_TYPE)
|
||||
}
|
||||
|
||||
func isAppError(typeName string) bool {
|
||||
return strings.Contains(typeName, APP_ERROR_TYPE)
|
||||
return strings.Contains(typeName, ERROR_TYPE)
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -256,14 +251,6 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
||||
}
|
||||
return "true"
|
||||
},
|
||||
"isAppError": func(results []string) bool {
|
||||
for _, typeName := range results {
|
||||
if isAppError(typeName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
"errorPresent": func(results []string) bool {
|
||||
for _, typeName := range results {
|
||||
if isError(typeName) {
|
||||
|
||||
@@ -60,25 +60,21 @@ func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinPa
|
||||
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
{{else}}
|
||||
{{if $element.Results | errorPresent}}
|
||||
{{if $element.Results | isAppError}}
|
||||
return s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
{{else}}
|
||||
tries := 0
|
||||
for {
|
||||
{{genResultsVars $element.Results false }} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
if {{$element.Results | errorVar}} == nil {
|
||||
return {{genResultsVars $element.Results true }}
|
||||
}
|
||||
if !isRepeatableError({{$element.Results | errorVar}}) {
|
||||
return {{genResultsVars $element.Results false }}
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
{{$element.Results | errorVar}} = errors.Wrap({{$element.Results | errorVar}}, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return {{genResultsVars $element.Results false }}
|
||||
}
|
||||
tries := 0
|
||||
for {
|
||||
{{genResultsVars $element.Results false }} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
if {{$element.Results | errorVar}} == nil {
|
||||
return {{genResultsVars $element.Results true }}
|
||||
}
|
||||
{{end}}
|
||||
if !isRepeatableError({{$element.Results | errorVar}}) {
|
||||
return {{genResultsVars $element.Results false }}
|
||||
}
|
||||
tries++
|
||||
if tries >= 3 {
|
||||
{{$element.Results | errorVar}} = errors.Wrap({{$element.Results | errorVar}}, "giving up after 3 consecutive repeatable transaction failures")
|
||||
return {{genResultsVars $element.Results false }}
|
||||
}
|
||||
}
|
||||
{{else}}
|
||||
return s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user