-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Description
Motivation:
checkpoint.Creator and fileProvider are awkward abstraction, especially when using it externally, e.g. new checkpoint create import cmd.
Problem:
Creator is responsible for storing checkpoints as well creating them (abstraction smell).
Proposed Solution:
I suggest to get rid of checkpoint.CreateRestorer entirely and instead define:
// Store manages checkpoint persistence.
type Store interface {
ChunkProvider
// GetCheckpoint retrieves checkpoint metadata for a specific checkpoint.
GetCheckpoint(ctx context.Context, version uint16, root node.Root) (*Metadata, error)
// DeleteCheckpoint deletes a specific checkpoint.
DeleteCheckpoint(ctx context.Context, version uint16, root node.Root) error
// AddCheckpoint begins a new checkpoint write transaction.
AddCheckpoint(ctx context.Context, root node.Root) (CheckpointWriter, error)
}
type CheckpointWriter interface {
writerFactory
Finalize(meta *Metadata) error
Abort() error
}Creating a checkpoint should be instead a package level function:
func CreateCheckpoint(ctx context.Context, ndb db.NodeDB, store Store, root node.Root, chunkSize uint64, chunkerThreads uint16) (*Metadata, error) {and checkpoint.fileCreator becomes checkpoint.FileStore.
Finally the following change is made to the storage API:
- // Checkpointer returns the checkpoint creator/restorer for this storage backend.
- Checkpointer() checkpoint.CreateRestorer
+ // CheckpointStore returns the checkpoint store for this storage backend.
+ CheckpointStore() checkpoint.Store
+
+ // CheckpointRestorer returns the checkpoint restorer for this storage backend.
+ CheckpointRestorer() *checkpoint.Restorer
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels