github.com/sandwich-go/boost@v1.3.29/retry/option.go (about) 1 package retry 2 3 import ( 4 "context" 5 "time" 6 ) 7 8 //go:generate optionGen --option_return_previous=false 9 func OptionsOptionDeclareWithDefault() interface{} { 10 return map[string]interface{}{ 11 // annotation@Limit(comment="最大尝试次数") 12 "Limit": uint(10), 13 // annotation@Delay(comment="固定延迟") 14 "Delay": time.Duration(100 * time.Millisecond), 15 // annotation@MaxJitter(comment="延迟最大抖动") 16 "MaxJitter": time.Duration(100 * time.Millisecond), 17 // annotation@OnRetry(comment="每次重试会先调用此方法") 18 "OnRetry": func(n uint, err error) { /*do nothing now*/ }, 19 // annotation@RetryIf(comment="何种error进行重试") 20 "RetryIf": (func(err error) bool)(IsRecoverable), 21 // annotation@DelayType(comment="何种error进行重试") 22 "DelayType": DelayTypeFunc(CombineDelay(BackOffDelay, RandomDelay)), 23 // annotation@LastErrorOnly(comment="是否只返回最后遇到的error") 24 "LastErrorOnly": false, 25 // annotation@Context(comment="context,可以设定超时等") 26 "Context": context.Context(context.Background()), 27 // annotation@MaxDelay(comment="最大延迟时间") 28 "MaxDelay": time.Duration(0), 29 "MaxBackOffNInner": uint(0), 30 } 31 }