Skip to content

Commit ad5754b

Browse files
authored
Merge pull request #475 from databacker/info-message-complete
Info message complete
2 parents 13ff350 + 846c969 commit ad5754b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pkg/core/dump.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ func (e *Executor) Dump(ctx context.Context, opts DumpOptions) (DumpResults, err
185185
uploadSpan.SetStatus(codes.Ok, "completed")
186186
uploadSpan.End()
187187

188+
logger.Infof("finished dump %s", now.Format(time.RFC3339))
189+
188190
return results, nil
189191
}
190192

pkg/core/timer.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ type Update struct {
2121
// Last whether or not this is the last update, and no more will be coming.
2222
// If true, perform this action and then end.
2323
Last bool
24+
// Next time until the next update, if applicable.
25+
Next time.Duration
2426
}
2527

26-
func sendTimer(c chan Update, last bool) {
28+
func sendTimer(c chan Update, last bool, next time.Duration) {
2729
// make the channel write non-blocking
2830
select {
29-
case c <- Update{Last: last}:
31+
case c <- Update{Last: last, Next: next}:
3032
default:
3133
}
3234
}
@@ -66,17 +68,14 @@ func Timer(opts TimerOptions) (<-chan Update, error) {
6668

6769
// if once, ignore all delays and go
6870
if opts.Once {
69-
sendTimer(c, true)
71+
sendTimer(c, true, 0)
7072
return
7173
}
7274

7375
// create our delay and timer loop and go
7476
for {
7577
lastRun := time.Now().UTC()
7678

77-
// not once - run the first backup
78-
sendTimer(c, false)
79-
8079
if opts.Cron != "" {
8180
now := time.Now().UTC()
8281
delay, _ = waitForCron(opts.Cron, now)
@@ -95,6 +94,9 @@ func Timer(opts TimerOptions) (<-chan Update, error) {
9594
delay = time.Duration(opts.Frequency-passed) * time.Minute
9695
}
9796

97+
// not once - run the first backup
98+
sendTimer(c, false, delay)
99+
98100
// if delayMins is 0, this will do nothing, so it does not hurt
99101
time.Sleep(delay)
100102
}
@@ -178,6 +180,7 @@ func (e *Executor) Timer(timerOpts TimerOptions, cmd func() error) error {
178180
if update.Last {
179181
break
180182
}
183+
e.Logger.Infof("next run in %s", update.Next.String())
181184
}
182185
return nil
183186
}

0 commit comments

Comments
 (0)