Gets public IP every hour
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
type Looper interface {
|
||||
Run(ctx context.Context, restart <-chan struct{})
|
||||
RunRestartTicker(ctx context.Context, restart chan<- struct{})
|
||||
}
|
||||
|
||||
type looper struct {
|
||||
@@ -71,3 +72,16 @@ func (l *looper) Run(ctx context.Context, restart <-chan struct{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (l *looper) RunRestartTicker(ctx context.Context, restart chan<- struct{}) {
|
||||
ticker := time.NewTicker(time.Hour)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
ticker.Stop()
|
||||
return
|
||||
case <-ticker.C:
|
||||
restart <- struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user