Skip to content

Commit 6ae220c

Browse files
committed
default
1 parent 590e750 commit 6ae220c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ddns/ddns.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/spf13/viper"
1313
)
1414

15+
// Run performs a one time DDNS update.
1516
func Run(ctx context.Context) error {
1617
ip, err := ip.GetPublicIPWithRetry(10, 5*time.Second)
1718
if err != nil {
@@ -27,10 +28,18 @@ func Run(ctx context.Context) error {
2728
return errors.Trace(err)
2829
}
2930

30-
func Daemon(ctx context.Context) error {
31-
updatePeriod := 10 * time.Second
32-
failureRetryDelay := updatePeriod
31+
// DaemonWithDefaults calls Daemon but with default values
32+
// updatePeriod - 10 seconds
33+
// failureRetryDelay - 10 seconds
34+
func DaemonWithDefaults(ctx context.Context) error {
35+
d := 10 * time.Second
36+
return errors.Trace(Daemon(ctx, d, d))
37+
}
3338

39+
// Daemon continually keeps DDNS up to date.
40+
// updatePeriod - how often to check for updates
41+
// failureRetryDelay - how long to wait until retry after a failure
42+
func Daemon(ctx context.Context, updatePeriod, failureRetryDelay time.Duration) error {
3443
var lastIP string
3544
var lastIPUpdate time.Time
3645

ddns/ddns_test.go

Whitespace-only changes.

0 commit comments

Comments
 (0)