You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by li...@apache.org on 2021/02/21 02:00:51 UTC
[skywalking-satellite] 01/01: plish timer fallbacker
This is an automated email from the ASF dual-hosted git repository.
liujiapeng pushed a commit to branch polish-codes
in repository https://gitbox.apache.org/repos/asf/skywalking-satellite.git
commit 7541f706bb62f59a75548a2e22c4f18b59e74b4d
Author: Evan <ev...@outlook.com>
AuthorDate: Sun Feb 21 10:00:32 2021 +0800
plish timer fallbacker
---
.../setup/plugins/fallbacker_timer-fallbacker.md | 13 ++++++-----
plugins/fallbacker/timer/timer_fallbacker.go | 27 +++++++++++-----------
plugins/fallbacker/timer/timer_fallbacker_test.go | 16 ++++++-------
3 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/docs/en/setup/plugins/fallbacker_timer-fallbacker.md b/docs/en/setup/plugins/fallbacker_timer-fallbacker.md
index 29f5ebd..e3cbacd 100755
--- a/docs/en/setup/plugins/fallbacker_timer-fallbacker.md
+++ b/docs/en/setup/plugins/fallbacker_timer-fallbacker.md
@@ -3,11 +3,12 @@
This is a timer fallback trigger to process the forward failure data.
## DefaultConfig
```yaml
-# 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.)
+# The forwarder max attempt times.
+max_attempts: 3
+# The exponential_backoff 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.)
+exponential_backoff: 2000
+# The max latency time used in retrying, which would override the latency time when the latency time
+# with exponential increasing larger than it.(Time unit is millisecond.)
max_latency_time: 5000
```
diff --git a/plugins/fallbacker/timer/timer_fallbacker.go b/plugins/fallbacker/timer/timer_fallbacker.go
index 06e4a95..7362def 100644
--- a/plugins/fallbacker/timer/timer_fallbacker.go
+++ b/plugins/fallbacker/timer/timer_fallbacker.go
@@ -30,9 +30,9 @@ 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"`
- MaxLatencyTIme int `mapstructure:"max_latency_time"`
+ MaxAttempts int `mapstructure:"max_attempts"`
+ ExponentialBackoff int `mapstructure:"exponential_backoff"`
+ MaxLatencyTime int `mapstructure:"max_latency_time"`
}
func (t *Fallbacker) Name() string {
@@ -45,24 +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.)
+# The forwarder max attempt times.
+max_attempts: 3
+# The exponential_backoff 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.)
+exponential_backoff: 2000
+# The max latency time used in retrying, which would override the latency time when the latency time
+# with exponential increasing larger than it.(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.ExponentialBackoff
+ for i := 1; i < t.MaxAttempts; i++ {
time.Sleep(time.Duration(currentLatency) * time.Millisecond)
if err := forward(batch); err != nil {
currentLatency *= 2
- if currentLatency > t.MaxLatencyTIme {
- currentLatency = t.MaxLatencyTIme
+ if currentLatency > t.MaxLatencyTime {
+ currentLatency = t.MaxLatencyTime
}
} else {
return true
diff --git a/plugins/fallbacker/timer/timer_fallbacker_test.go b/plugins/fallbacker/timer/timer_fallbacker_test.go
index d294eb3..286114c 100644
--- a/plugins/fallbacker/timer/timer_fallbacker_test.go
+++ b/plugins/fallbacker/timer/timer_fallbacker_test.go
@@ -63,21 +63,21 @@ func TestFallbacker_FallBack1(t1 *testing.T) {
wantCount: 2,
},
{
- name: "test-recach-max_times",
+ name: "test-recach-max_attempts",
args: plugin.Config{
- "max_times": 5,
- "latency_factor": 200,
- "max_latency_time": 3000,
+ "max_attempts": 5,
+ "exponential_backoff": 200,
+ "max_latency_time": 3000,
},
want: true,
wantCount: 4,
},
{
- name: "test-unrecach-max_times",
+ name: "test-unrecach-max_attempts",
args: plugin.Config{
- "max_times": 10,
- "latency_factor": 20,
- "max_latency_time": 30000000,
+ "max_attempts": 10,
+ "exponential_backoff": 20,
+ "max_latency_time": 30000000,
},
want: true,
wantCount: 4,