WIP daemon:

Implement
* pruning on source side
* local job
* test subcommand for doing a dry-run of a prune policy

* use a non-blocking callback from autosnap to trigger the depending
jobs -> avoids races, looks saner in the debug log
This commit is contained in:
Christian Schwarz
2017-09-16 21:12:26 +02:00
parent b168274048
commit 6a05e101cf
7 changed files with 333 additions and 47 deletions
+20 -3
View File
@@ -93,12 +93,13 @@ func (j *PullJob) JobName() string {
func (j *PullJob) JobStart(ctx context.Context) {
log := ctx.Value(contextKeyLog).(Logger)
defer log.Printf("exiting")
ticker := time.NewTicker(j.Interval)
start:
log := ctx.Value(contextKeyLog).(Logger)
log.Printf("connecting")
rwc, err := j.Connect.Connect()
if err != nil {
@@ -128,7 +129,12 @@ start:
log.Printf("starting prune")
prunectx := context.WithValue(ctx, contextKeyLog, util.NewPrefixLogger(log, "prune"))
pruner := Pruner{time.Now(), false, j.pruneFilter, j.SnapshotPrefix, j.Prune}
pruner, err := j.Pruner(PrunePolicySideDefault, false)
if err != nil {
log.Printf("error creating pruner: %s", err)
return
}
pruner.Run(prunectx)
log.Printf("finish prune")
@@ -143,6 +149,17 @@ start:
}
func (j *PullJob) Pruner(side PrunePolicySide, dryRun bool) (p Pruner, err error) {
p = Pruner{
time.Now(),
dryRun,
j.pruneFilter,
j.SnapshotPrefix,
j.Prune,
}
return
}
func (j *PullJob) doRun(ctx context.Context) {
}