-
Notifications
You must be signed in to change notification settings - Fork 479
/
config_retry.go
48 lines (40 loc) · 1.38 KB
/
config_retry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package otelcol
import (
"time"
"github.com/grafana/agent/pkg/river"
otelexporterhelper "go.opentelemetry.io/collector/exporter/exporterhelper"
)
// RetryArguments holds shared settings for components which can retry
// requests.
type RetryArguments struct {
Enabled bool `river:"enabled,attr,optional"`
InitialInterval time.Duration `river:"initial_interval,attr,optional"`
MaxInterval time.Duration `river:"max_interval,attr,optional"`
MaxElapsedTime time.Duration `river:"max_elapsed_time,attr,optional"`
}
var _ river.Unmarshaler = (*RetryArguments)(nil)
// DefaultRetryArguments holds default settings for RetryArguments.
var DefaultRetryArguments = RetryArguments{
Enabled: true,
InitialInterval: 5 * time.Second,
MaxInterval: 30 * time.Second,
MaxElapsedTime: 5 * time.Minute,
}
// UnmarshalRiver implements river.Unmarshaler.
func (args *RetryArguments) UnmarshalRiver(f func(interface{}) error) error {
*args = DefaultRetryArguments
type arguments RetryArguments
return f((*arguments)(args))
}
// Convert converts args into the upstream type.
func (args *RetryArguments) Convert() *otelexporterhelper.RetrySettings {
if args == nil {
return nil
}
return &otelexporterhelper.RetrySettings{
Enabled: args.Enabled,
InitialInterval: args.InitialInterval,
MaxInterval: args.MaxInterval,
MaxElapsedTime: args.MaxElapsedTime,
}
}