Gets public IP every hour

This commit is contained in:
Quentin McGaw
2020-07-08 22:47:12 +00:00
parent 2c96f91043
commit ad73a027f3
2 changed files with 15 additions and 0 deletions

View File

@@ -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{}{}
}
}
}