2022-02-07 09:42:07 +00:00
|
|
|
package supervisor
|
2020-04-30 05:02:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ReconnectSignal struct {
|
|
|
|
// wait this many seconds before re-establish the connection
|
|
|
|
Delay time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error allows us to use ReconnectSignal as a special error to force connection abort
|
2021-01-20 17:52:35 +00:00
|
|
|
func (r ReconnectSignal) Error() string {
|
2020-04-30 05:02:08 +00:00
|
|
|
return "reconnect signal"
|
|
|
|
}
|
|
|
|
|
2021-01-20 17:52:35 +00:00
|
|
|
func (r ReconnectSignal) DelayBeforeReconnect() {
|
2020-04-30 05:02:08 +00:00
|
|
|
if r.Delay > 0 {
|
|
|
|
time.Sleep(r.Delay)
|
|
|
|
}
|
|
|
|
}
|