Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- package icecast
-
- import "time"
-
- type ReconnectConfig struct {
- Enabled bool
- InitialBackoffMs int
- MaxBackoffMs int
- }
-
- func (c ReconnectConfig) nextBackoff(attempt int) time.Duration {
- if !c.Enabled {
- return 0
- }
- initial := c.InitialBackoffMs
- if initial <= 0 {
- initial = 1000
- }
- max := c.MaxBackoffMs
- if max <= 0 {
- max = 15000
- }
- d := time.Duration(initial) * time.Millisecond
- for i := 1; i < attempt; i++ {
- d *= 2
- if d >= time.Duration(max)*time.Millisecond {
- return time.Duration(max) * time.Millisecond
- }
- }
- return d
- }
|