You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/02/21 01:32:52 UTC
[GitHub] [skywalking-satellite] kezhenxu94 commented on a change in pull request #30: add timer fallbacker unit test
kezhenxu94 commented on a change in pull request #30:
URL: https://github.com/apache/skywalking-satellite/pull/30#discussion_r579732354
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -25,16 +25,18 @@ import (
"github.com/apache/skywalking-satellite/plugins/forwarder/api"
)
-// Fallbacker is a timer fallbacker when forward fails. `latencyFactor` is the standard retry duration,
-// and the time for each retry is expanded by 2 times until the number of retries reaches the maximum.
+const Name = "timer-fallbacker"
+
+// Fallbacker is a timer fallbacker when forward fails.
type Fallbacker struct {
config.CommonFields
- maxTimes int `mapstructure:"max_times"`
- latencyFactor int `mapstructure:"latency_factor"`
+ MaxTimes int `mapstructure:"max_times"`
+ LatencyFactor int `mapstructure:"latency_factor"`
Review comment:
s/LatencyFactor/ExponentialBackoff
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -43,17 +45,25 @@ func (t *Fallbacker) Description() string {
func (t *Fallbacker) DefaultConfig() string {
return `
+# The forwarder max retry times.
max_times: 3
+# The latency_factor is the standard retry duration, and the time for each retry is expanded by 2 times until the number
+# of retries reaches the maximum.(Time unit is millisecond.)
latency_factor: 2000
+# The max retry latency time.(Time unit is millisecond.)
+max_latency_time: 5000
`
}
func (t *Fallbacker) FallBack(batch event.BatchEvents, forward api.ForwardFunc) bool {
- currentLatency := t.latencyFactor
- for i := 1; i < t.maxTimes; i++ {
+ currentLatency := t.LatencyFactor
+ for i := 1; i < t.MaxTimes; i++ {
Review comment:
```suggestion
for i := 1; i <= t.MaxTimes; i++ {
```
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -25,16 +25,18 @@ import (
"github.com/apache/skywalking-satellite/plugins/forwarder/api"
)
-// Fallbacker is a timer fallbacker when forward fails. `latencyFactor` is the standard retry duration,
-// and the time for each retry is expanded by 2 times until the number of retries reaches the maximum.
+const Name = "timer-fallbacker"
+
+// Fallbacker is a timer fallbacker when forward fails.
type Fallbacker struct {
config.CommonFields
- maxTimes int `mapstructure:"max_times"`
- latencyFactor int `mapstructure:"latency_factor"`
+ MaxTimes int `mapstructure:"max_times"`
Review comment:
s/MaxTimes/MaxAttempts
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -43,17 +45,25 @@ func (t *Fallbacker) Description() string {
func (t *Fallbacker) DefaultConfig() string {
return `
+# The forwarder max retry times.
max_times: 3
+# The latency_factor is the standard retry duration, and the time for each retry is expanded by 2 times until the number
+# of retries reaches the maximum.(Time unit is millisecond.)
latency_factor: 2000
+# The max retry latency time.(Time unit is millisecond.)
+max_latency_time: 5000
`
}
func (t *Fallbacker) FallBack(batch event.BatchEvents, forward api.ForwardFunc) bool {
- currentLatency := t.latencyFactor
- for i := 1; i < t.maxTimes; i++ {
+ currentLatency := t.LatencyFactor
+ for i := 1; i < t.MaxTimes; i++ {
time.Sleep(time.Duration(currentLatency) * time.Millisecond)
if err := forward(batch); err != nil {
currentLatency *= 2
+ if currentLatency > t.MaxLatencyTIme {
Review comment:
```suggestion
if currentLatency >= t.MaxLatencyTIme {
```
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -43,17 +45,25 @@ func (t *Fallbacker) Description() string {
func (t *Fallbacker) DefaultConfig() string {
return `
+# The forwarder max retry times.
max_times: 3
+# The latency_factor is the standard retry duration, and the time for each retry is expanded by 2 times until the number
+# of retries reaches the maximum.(Time unit is millisecond.)
latency_factor: 2000
+# The max retry latency time.(Time unit is millisecond.)
+max_latency_time: 5000
`
}
func (t *Fallbacker) FallBack(batch event.BatchEvents, forward api.ForwardFunc) bool {
- currentLatency := t.latencyFactor
- for i := 1; i < t.maxTimes; i++ {
+ currentLatency := t.LatencyFactor
+ for i := 1; i < t.MaxTimes; i++ {
time.Sleep(time.Duration(currentLatency) * time.Millisecond)
if err := forward(batch); err != nil {
currentLatency *= 2
+ if currentLatency > t.MaxLatencyTIme {
+ currentLatency = t.MaxLatencyTIme
Review comment:
??
```suggestion
return false
```
##########
File path: plugins/fallbacker/timer/timer_fallbacker.go
##########
@@ -43,17 +45,25 @@ func (t *Fallbacker) Description() string {
func (t *Fallbacker) DefaultConfig() string {
return `
+# The forwarder max retry times.
max_times: 3
+# The latency_factor is the standard retry duration, and the time for each retry is expanded by 2 times until the number
+# of retries reaches the maximum.(Time unit is millisecond.)
latency_factor: 2000
+# The max retry latency time.(Time unit is millisecond.)
+max_latency_time: 5000
`
}
func (t *Fallbacker) FallBack(batch event.BatchEvents, forward api.ForwardFunc) bool {
- currentLatency := t.latencyFactor
- for i := 1; i < t.maxTimes; i++ {
+ currentLatency := t.LatencyFactor
+ for i := 1; i < t.MaxTimes; i++ {
time.Sleep(time.Duration(currentLatency) * time.Millisecond)
if err := forward(batch); err != nil {
currentLatency *= 2
+ if currentLatency > t.MaxLatencyTIme {
+ currentLatency = t.MaxLatencyTIme
Review comment:
Add this test case please
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org