mirror of
https://github.com/miniflux/v2.git
synced 2025-09-30 19:22:11 +00:00
Merge 63b1279792
into 8adcaed29e
This commit is contained in:
commit
62c01abfbb
4 changed files with 16 additions and 5 deletions
|
@ -489,8 +489,8 @@ func NewConfigOptions() *configOptions {
|
|||
},
|
||||
},
|
||||
"POLLING_PARSING_ERROR_LIMIT": {
|
||||
ParsedIntValue: 3,
|
||||
RawValue: "3",
|
||||
ParsedIntValue: 0,
|
||||
RawValue: "0",
|
||||
ValueType: intType,
|
||||
Validator: func(rawValue string) error {
|
||||
return validateGreaterOrEqualThan(rawValue, 0)
|
||||
|
|
|
@ -1058,8 +1058,8 @@ func TestPollingLimitPerHostOptionParsing(t *testing.T) {
|
|||
func TestPollingParsingErrorLimitOptionParsing(t *testing.T) {
|
||||
configParser := NewConfigParser()
|
||||
|
||||
if configParser.options.PollingParsingErrorLimit() != 3 {
|
||||
t.Fatalf("Expected POLLING_PARSING_ERROR_LIMIT to be 3 by default")
|
||||
if configParser.options.PollingParsingErrorLimit() != 0 {
|
||||
t.Fatalf("Expected POLLING_PARSING_ERROR_LIMIT to be 0 by default")
|
||||
}
|
||||
|
||||
if err := configParser.parseLines([]string{"POLLING_PARSING_ERROR_LIMIT=5"}); err != nil {
|
||||
|
|
|
@ -6,6 +6,7 @@ package model // import "miniflux.app/v2/internal/model"
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"miniflux.app/v2/internal/config"
|
||||
|
@ -135,6 +136,16 @@ func (f *Feed) ScheduleNextCheck(weeklyCount int, refreshDelay time.Duration) ti
|
|||
// Use the RSS TTL field, Retry-After, Cache-Control or Expires HTTP headers if defined.
|
||||
interval = max(interval, refreshDelay)
|
||||
|
||||
// Use a binary exponential backoff for feeds with parsing errors.
|
||||
// https://en.wikipedia.org/wiki/Exponential_backoff
|
||||
if f.ParsingErrorCount > 0 {
|
||||
backoff := time.Duration(math.Pow(2, float64(f.ParsingErrorCount))) * time.Hour
|
||||
// Set a hard limit at one week
|
||||
if backoff.Hours() < time.Hour.Hours()*24*7 {
|
||||
interval += backoff
|
||||
}
|
||||
}
|
||||
|
||||
// Limit the max interval value for misconfigured feeds.
|
||||
switch config.Opts.PollingScheduler() {
|
||||
case SchedulerRoundRobin:
|
||||
|
|
|
@ -504,7 +504,7 @@ The maximum number of parsing errors that the program will try before stopping p
|
|||
.br
|
||||
Once the limit is reached, the user must refresh the feed manually. Set to 0 for unlimited.
|
||||
.br
|
||||
Default is 3\&.
|
||||
Default is 0\&.
|
||||
.TP
|
||||
.B POLLING_SCHEDULER
|
||||
Determines the strategy used to schedule feed polling.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue