Documentation
¶
Overview ¶
Package migration moves node-local project data — per-instance kvdbs under /crdt/<hash> and locally-held storage file bytes — into hoarder-hosted instances and the hoarder stash, then scrubs the local copies. It runs at substrate boot (bounded, then background) and is idempotent: every pass re-enumerates what is still local, replays it conditionally (putnx — a value written through the live path is never overwritten), verifies by read-back, and only then deletes. Source data is never deleted before verified read-back; unresolvable namespaces are left intact and reported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // BootTimeout bounds the synchronous boot-time pass; work left when it // expires continues in the background (the node serves meanwhile). BootTimeout = 10 * time.Minute // DrainInterval is the background retry period while local data remains — // it picks up instances that become resolvable later (a hoarder meta // appears when live traffic first-touches a regex-matched instance) and // retries transient failures. DrainInterval = 30 * time.Second // ReplayWorkers is the per-instance bound on in-flight key replays. ReplayWorkers = 8 )
Tunables — exported so tests can shrink them.
Functions ¶
func Entries ¶
Entries reads every logical key/value of one namespace through the offline view — never announcing heads, never touching the network.
Types ¶
type InstanceReport ¶
type InstanceReport struct {
Match string
Kind string
Written int // keys replayed (absent remotely)
Existed int // keys already present remotely with the same value
Superseded int // keys present remotely with a different value (live write wins)
FilesStashed int // locally-held file bytes pushed to the stash this pass
FilesAwaitingRepl int // locally-held file bytes below the stash replica target
FilesElsewhere int // file bytes this node never held (another holder pushes)
Verified bool // every local key read back through the hoarder path
Scrubbed bool // local namespace deleted (implies Verified + bytes at target)
Err string
// contains filtered or unexported fields
}
InstanceReport is the per-instance outcome of one pass.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator owns the migration lifecycle for one substrate node.
func New ¶
func New(ctx context.Context, node peer.Node, hoarder hoarderIface.Client, tns tnsIface.Client) *Migrator
New builds a Migrator. ctx is the service lifetime: Close cancels its child and joins any background work before returning.
func (*Migrator) Boot ¶
Boot runs the synchronous boot-time pass, bounded by BootTimeout. A node with no local project data pays one prefix query. Work left at the bound — or instances that need live traffic to become resolvable — continues on the background drain.
func (*Migrator) Close ¶
func (m *Migrator) Close()
Close stops background work and joins it — a canceled drain must not touch the node's store or the clients while the service tears them down.
func (*Migrator) Migrate ¶
Migrate runs one full pass: enumerate → resolve → replay → verify → scrub → sweep. Safe to re-run at any time; passes serialize. Nothing local is deleted unless its instance verified read-back through the hoarder path and (for storage bytes) the stash reached its replica target.
type Report ¶
type Report struct {
Instances map[string]*InstanceReport
Unresolved []string // namespaces with no identity yet — left intact, retried
SweptKeys int // raw namespace keys deleted
SweptBlocks int // blockstore blocks deleted
Err string
}
Report is the outcome of one Migrate pass.
func (*Report) RemainingCount ¶
RemainingCount is how many local namespaces still hold data after the pass.