migration

package
v1.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package migration moves a single (org, namespace) shard between nodes. The protocol is:

  1. Lock the source shard via a consensus barrier (Replicator Propose with Op="lock"). Until the lock-frame is accepted on every replica, the shard remains writable.
  2. WAL-checkpoint and copy the SQLite file to the destination.
  3. Replay any frames whose Seq is >= the last sequence captured at barrier time. (No-op for the local driver, since Propose is synchronous.)
  4. Release the lock with another Propose (Op="unlock"); the destination becomes the live shard owner.

CLI: tasksd migrate --org <id> --namespace <name> --to <node>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator runs migrations against a Manager + Replicator pair.

func NewCoordinator

func NewCoordinator(mgr *store.Manager, rep replication.Replicator) *Coordinator

NewCoordinator wires a fresh coordinator.

func (*Coordinator) Get

func (c *Coordinator) Get(id string) *Job

Get returns a job by id, or nil if unknown.

func (*Coordinator) List

func (c *Coordinator) List() []Job

List returns every job the coordinator has seen.

func (*Coordinator) Migrate

func (c *Coordinator) Migrate(ctx context.Context, j Job) (*Job, error)

Migrate runs a job synchronously.

type Job

type Job struct {
	ID         string    `json:"id"`
	OrgID      string    `json:"org"`
	Namespace  string    `json:"ns"`
	From       string    `json:"from"`
	To         string    `json:"to"`
	Status     Status    `json:"status"`
	Error      string    `json:"error,omitempty"`
	Bytes      int64     `json:"bytes"`
	StartedAt  time.Time `json:"startedAt"`
	FinishedAt time.Time `json:"finishedAt,omitempty"`
}

Job is a single migration unit.

type Status

type Status string

Status reflects a migration's lifecycle.

const (
	StatusPending   Status = "pending"
	StatusLocking   Status = "locking"
	StatusCopying   Status = "copying"
	StatusReplaying Status = "replaying"
	StatusReleased  Status = "released"
	StatusFailed    Status = "failed"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL