Documentation ¶
Index ¶
Constants ¶
const ( // FileKindRsync denotes rsync patching (blocks-based) FileKindRsync = 1 // FileKindBsdiff denotes bsdiff patching (addition-based) FileKindBsdiff = 2 )
Variables ¶
var ErrStop = fmt.Errorf("patching was stopped after save!")
ErrStop is returned by `patcher.Resume` if it just saved a checkpoint and the `SaveConsumer` returned `AfterSaveStop`.
Functions ¶
func PatchFresh ¶
func PatchFresh(params PatchFreshParams) error
Types ¶
type AfterSaveAction ¶
type AfterSaveAction int
AfterSaveAction describes what the patcher should do after it saved. This can be used to gracefully stop it.
const ( // AfterSaveContinue indicates that the patcher should continue after saving. AfterSaveContinue AfterSaveAction = 1 // AfterSaveStop indicates that the patcher should stop and return ErrStop AfterSaveStop AfterSaveAction = 2 )
type BsdiffCheckpoint ¶
type BsdiffCheckpoint struct { WriterCheckpoint *bowl.WriterCheckpoint // instructions in bsdiff are relative seeks, so we need to keep track of // the offset in the (single) target file OldOffset int64 // bsdiff series are applied against a single target file, and its index // is in a past message, so we need to keep track of it TargetIndex int64 }
BsdiffCheckpoint is used when saving a patcher checkpoint in the middle of patching a file with bsdiff instructions.
type Checkpoint ¶
type Checkpoint struct { MessageCheckpoint *wire.MessageReaderCheckpoint FileIndex int64 FileKind FileKind BowlCheckpoint *bowl.BowlCheckpoint SyncHeader *pwr.SyncHeader RsyncCheckpoint *RsyncCheckpoint BsdiffCheckpoint *BsdiffCheckpoint }
Checkpoint contains state information for a patcher that can be written to disk and read back from disk to resume roughly where we left off.
type PatchFreshParams ¶
type Patcher ¶
type Patcher interface { SetSaveConsumer(sc SaveConsumer) Resume(checkpoint *Checkpoint, targetPool lake.Pool, bowl bowl.Bowl) error Progress() float64 GetSourceContainer() *tlc.Container GetTargetContainer() *tlc.Container SetSourceIndexWhitelist(sourceIndexWhitelist map[int64]bool) GetTouchedFiles() int64 }
A Patcher applies a wharf patch, either standard (rsync-only) or optimized (rsync + bsdiff). It can save its progress and resume. It patches to a bowl: fresh bowls (create new folder with new build), overlay bowls (patch to overlay, then commit that overlay in-place), etc.
type RsyncCheckpoint ¶
type RsyncCheckpoint struct {
WriterCheckpoint *bowl.WriterCheckpoint
}
RsyncCheckpoint is used when saving a patcher checkpoint in the middle of patching a file with rsync instructions.
type SaveConsumer ¶
type SaveConsumer interface { ShouldSave() bool Save(c *Checkpoint) (AfterSaveAction, error) }
A SaveConsumer can be set on a Patcher to decide if the patcher should save (whenever it reaches a convenient place for a checkpoint), and to receive the checkpoints, and let the patcher know if it should stop or continue