mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 01:44:43 +01:00
4e16952ad9
1. Change config format to support multiple types of snapshotting modes. 2. Implement a hacky way to support periodic or completely manual snaphots. In manual mode, the user has to trigger replication using the wakeup mechanism after they took snapshots using their own tooling. As indicated by the comment, a more general solution would be desirable, but we want to get the release out and 'manual' mode is a feature that some people requested...
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package snapper
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zrepl/zrepl/config"
|
|
"github.com/zrepl/zrepl/daemon/filters"
|
|
)
|
|
|
|
// FIXME: properly abstract snapshotting:
|
|
// - split up things that trigger snapshotting from the mechanism
|
|
// - timer-based trigger (periodic)
|
|
// - call from control socket (manual)
|
|
// - mixed modes?
|
|
// - support a `zrepl snapshot JOBNAME` subcommand for config.SnapshottingManual
|
|
type PeriodicOrManual struct {
|
|
s *Snapper
|
|
}
|
|
|
|
func (s *PeriodicOrManual) Run(ctx context.Context, wakeUpCommon chan <- struct{}) {
|
|
if s.s != nil {
|
|
s.s.Run(ctx, wakeUpCommon)
|
|
}
|
|
}
|
|
|
|
func FromConfig(g *config.Global, fsf *filters.DatasetMapFilter, in config.SnapshottingEnum) (*PeriodicOrManual, error) {
|
|
switch v := in.Ret.(type) {
|
|
case *config.SnapshottingPeriodic:
|
|
snapper, err := PeriodicFromConfig(g, fsf, v)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &PeriodicOrManual{snapper}, nil
|
|
case *config.SnapshottingManual:
|
|
return &PeriodicOrManual{}, nil
|
|
default:
|
|
return nil, fmt.Errorf("unknown snapshotting type %T", v)
|
|
}
|
|
}
|