Documentation
¶
Overview ¶
Package migrate provides a mechanism for arbitrary migration operations that should block startup, such as moving Etcd objects from one key to another. IMPORTANT: migrations _must_ be written to be idempotent, and we should prefer non-destructive updates in order to allow rollbacks.
server/internal/migrate/store.go
Index ¶
- Constants
- func Provide(i *do.Injector)
- type Migration
- type ResultStore
- type RevisionStore
- func (s *RevisionStore) Create(item *StoredRevision) storage.PutOp[*StoredRevision]
- func (s *RevisionStore) Get() storage.GetOp[*StoredRevision]
- func (s *RevisionStore) Key() string
- func (s *RevisionStore) Update(item *StoredRevision) storage.PutOp[*StoredRevision]
- func (s *RevisionStore) Watch() storage.WatchOp[*StoredRevision]
- type Runner
- type Store
- type StoredResult
- type StoredRevision
Constants ¶
const ElectionName = election.Name("migration_runner")
const LockTTL time.Duration = 30 * time.Second
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Migration ¶
type Migration interface {
// Identifier returns a unique semantic name for this migration.
Identifier() string
// Run executes the migration using dependencies from the injector.
// The context should be used for cancellation and timeouts.
Run(ctx context.Context, i *do.Injector) error
}
Migration defines the interface for data migrations.
func AllMigrations ¶
AllMigrations returns the ordered list of migrations. Order matters - migrations are executed in slice order. Add new migrations to this list in chronological order.
type ResultStore ¶
type ResultStore struct {
// contains filtered or unexported fields
}
func NewResultStore ¶
func NewResultStore(client *clientv3.Client, root string) *ResultStore
func (*ResultStore) Get ¶
func (s *ResultStore) Get(identifier string) storage.GetOp[*StoredResult]
func (*ResultStore) Key ¶
func (s *ResultStore) Key(identifier string) string
func (*ResultStore) Prefix ¶
func (s *ResultStore) Prefix() string
func (*ResultStore) Put ¶
func (s *ResultStore) Put(item *StoredResult) storage.PutOp[*StoredResult]
type RevisionStore ¶
type RevisionStore struct {
// contains filtered or unexported fields
}
func NewRevisionStore ¶
func NewRevisionStore(client *clientv3.Client, root string) *RevisionStore
func (*RevisionStore) Create ¶
func (s *RevisionStore) Create(item *StoredRevision) storage.PutOp[*StoredRevision]
func (*RevisionStore) Get ¶
func (s *RevisionStore) Get() storage.GetOp[*StoredRevision]
func (*RevisionStore) Key ¶
func (s *RevisionStore) Key() string
func (*RevisionStore) Update ¶
func (s *RevisionStore) Update(item *StoredRevision) storage.PutOp[*StoredRevision]
func (*RevisionStore) Watch ¶
func (s *RevisionStore) Watch() storage.WatchOp[*StoredRevision]
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner orchestrates migration execution with distributed locking.
type Store ¶
type Store struct {
Revision *RevisionStore
Result *ResultStore
}
Store wraps all migration-related stores.
type StoredResult ¶
type StoredResult struct {
storage.StoredValue
Identifier string `json:"identifier"`
Successful bool `json:"successful"`
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
RunByHostID string `json:"run_by_host_id"`
RunByVersionInfo *version.Info `json:"run_by_version_info"`
Error string `json:"error,omitempty"`
}
StoredResult tracks the outcome of a specific migration.
type StoredRevision ¶
type StoredRevision struct {
storage.StoredValue
Identifier string `json:"identifier"`
}
StoredRevision tracks the most recently applied migration.