Gofmt snapjob.go

This commit is contained in:
InsanePrawn 2018-11-21 14:02:21 +01:00
parent 22d9830baa
commit d0f898751f

View File

@ -15,9 +15,9 @@ import (
) )
type SnapJob struct { type SnapJob struct {
name string name string
fsfilter zfs.DatasetFilter fsfilter zfs.DatasetFilter
snapper *snapper.PeriodicOrManual snapper *snapper.PeriodicOrManual
prunerFactory *pruner.SinglePrunerFactory prunerFactory *pruner.SinglePrunerFactory
@ -26,19 +26,17 @@ type SnapJob struct {
pruner *pruner.Pruner pruner *pruner.Pruner
} }
func (j *SnapJob) Name() string { return j.name } func (j *SnapJob) Name() string { return j.name }
func (j *SnapJob) getPruner(ctx context.Context, sender *endpoint.Sender) (*pruner.Pruner) { func (j *SnapJob) getPruner(ctx context.Context, sender *endpoint.Sender) *pruner.Pruner {
p := j.prunerFactory.BuildSinglePruner(ctx,sender,sender) p := j.prunerFactory.BuildSinglePruner(ctx, sender, sender)
return p return p
} }
func (j *SnapJob) Type() Type { return TypeSnap } func (j *SnapJob) Type() Type { return TypeSnap }
func (j *SnapJob) RunPeriodic(ctx context.Context, wakeUpCommon chan <- struct{}) { func (j *SnapJob) RunPeriodic(ctx context.Context, wakeUpCommon chan<- struct{}) {
j.snapper.Run(ctx, wakeUpCommon) j.snapper.Run(ctx, wakeUpCommon)
} }
func (j *SnapJob) FSFilter() zfs.DatasetFilter { func (j *SnapJob) FSFilter() zfs.DatasetFilter {
@ -47,22 +45,22 @@ func (j *SnapJob) FSFilter() zfs.DatasetFilter {
func snapJob(g *config.Global, in *config.SnapJob) (j *SnapJob, err error) { func snapJob(g *config.Global, in *config.SnapJob) (j *SnapJob, err error) {
j = &SnapJob{} j = &SnapJob{}
fsf, err := filters.DatasetMapFilterFromConfig(in.Filesystems) fsf, err := filters.DatasetMapFilterFromConfig(in.Filesystems)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "cannnot build filesystem filter") return nil, errors.Wrap(err, "cannnot build filesystem filter")
} }
j.fsfilter = fsf j.fsfilter = fsf
if j.snapper, err = snapper.FromConfig(g, fsf, in.Snapshotting); err != nil { if j.snapper, err = snapper.FromConfig(g, fsf, in.Snapshotting); err != nil {
return nil, errors.Wrap(err, "cannot build snapper") return nil, errors.Wrap(err, "cannot build snapper")
} }
j.name = in.Name j.name = in.Name
j.promPruneSecs = prometheus.NewHistogramVec(prometheus.HistogramOpts{ j.promPruneSecs = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "zrepl", Namespace: "zrepl",
Subsystem: "pruning", Subsystem: "pruning",
Name: "time", Name: "time",
Help: "seconds spent in pruner", Help: "seconds spent in pruner",
ConstLabels: prometheus.Labels{"zrepl_job":j.name}, ConstLabels: prometheus.Labels{"zrepl_job": j.name},
}, []string{"prune_side"}) }, []string{"prune_side"})
j.prunerFactory, err = pruner.NewSinglePrunerFactory(in.Pruning, j.promPruneSecs) j.prunerFactory, err = pruner.NewSinglePrunerFactory(in.Pruning, j.promPruneSecs)
if err != nil { if err != nil {
@ -126,4 +124,3 @@ func (j *SnapJob) doPrune(ctx context.Context) {
j.pruner.Prune() j.pruner.Prune()
log.Info("finished pruning") log.Info("finished pruning")
} }