Removing AppError check from the retry layer (#16307)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cf4df5fcd2
Коммит
5b1a716e2c
@@ -20,16 +20,11 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
|
OPEN_TRACING_PARAMS_MARKER = "@openTracingParams"
|
||||||
APP_ERROR_TYPE = "*model.AppError"
|
|
||||||
ERROR_TYPE = "error"
|
ERROR_TYPE = "error"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isError(typeName string) bool {
|
func isError(typeName string) bool {
|
||||||
return strings.Contains(typeName, APP_ERROR_TYPE) || strings.Contains(typeName, ERROR_TYPE)
|
return strings.Contains(typeName, ERROR_TYPE)
|
||||||
}
|
|
||||||
|
|
||||||
func isAppError(typeName string) bool {
|
|
||||||
return strings.Contains(typeName, APP_ERROR_TYPE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -256,14 +251,6 @@ func generateLayer(name, templateFile string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
return "true"
|
return "true"
|
||||||
},
|
},
|
||||||
"isAppError": func(results []string) bool {
|
|
||||||
for _, typeName := range results {
|
|
||||||
if isAppError(typeName) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
"errorPresent": func(results []string) bool {
|
"errorPresent": func(results []string) bool {
|
||||||
for _, typeName := range results {
|
for _, typeName := range results {
|
||||||
if isError(typeName) {
|
if isError(typeName) {
|
||||||
|
|||||||
@@ -60,25 +60,21 @@ func (s *{{$.Name}}{{$substoreName}}Store) {{$index}}({{$element.Params | joinPa
|
|||||||
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if $element.Results | errorPresent}}
|
{{if $element.Results | errorPresent}}
|
||||||
{{if $element.Results | isAppError}}
|
tries := 0
|
||||||
return s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
for {
|
||||||
{{else}}
|
{{genResultsVars $element.Results false }} := s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||||
tries := 0
|
if {{$element.Results | errorVar}} == nil {
|
||||||
for {
|
return {{genResultsVars $element.Results true }}
|
||||||
{{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 }}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{{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}}
|
{{else}}
|
||||||
return s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
return s.{{$substoreName}}Store.{{$index}}({{$element.Params | joinParams}})
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user