migrate

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Overview

Package migrate provides helper functions for creation and migration of dynamic YT tables.

Index

Constants

This section is empty.

Variables

View Source
var ErrConflict = xerrors.NewSentinel("detected schema conflict during migration")
View Source
var RetryConflict error = &retrySentinel{}

RetryConflict is a sentinel value that might be returned from ConflictFn.

Functions

func Create

func Create(ctx context.Context, yc yt.Client, path ypath.Path, schema schema.Schema) error

Create creates new dynamic table with provided schema.

func EnsureTables

func EnsureTables(
	ctx context.Context,
	yc yt.Client,
	tables map[ypath.Path]Table,
	onConflict ConflictFn,
) error

EnsureTables creates and mounts dynamic tables.

If table with a given path already exists, but have a different schema, onConflict handler is invoked.

func FreezeAndWait

func FreezeAndWait(ctx context.Context, yc yt.Client, path ypath.Path) error

FreezeAndWait freezes dynamic table and waits for a table to become frozen.

func MountAndWait

func MountAndWait(ctx context.Context, yc yt.Client, path ypath.Path) error

MountAndWait mounts dynamic table and waits for a table to become mounted.

func OnConflictFail

func OnConflictFail(path ypath.Path, actual, expected schema.Schema) (err error)

OnConflictFail is ConflictFn that will just return ErrConflict.

func UnfreezeAndWait

func UnfreezeAndWait(ctx context.Context, yc yt.Client, path ypath.Path) error

UnfreezeAndWait unfreezes dynamic table and waits for a table to become mounted.

func UnmountAndWait

func UnmountAndWait(ctx context.Context, yc yt.Client, path ypath.Path) error

UnmountAndWait unmounts dynamic table and waits for a table to become unmounted.

Types

type ConflictFn

type ConflictFn func(path ypath.Path, actual, expected schema.Schema) error

ConflictFn is function called from migration routine for table that already exists but got unexpected schema.

func OnConflictDrop

func OnConflictDrop(ctx context.Context, yc yt.Client) ConflictFn

OnConflictDrop returns ConflictFn that will drop previous version for the table.

func OnConflictTryAlter

func OnConflictTryAlter(ctx context.Context, yc yt.Client) ConflictFn

OnConflictTryAlter returns ConflictFn that will try to alter previous version of the table.

type RetentionConfig

type RetentionConfig struct {
	MinDataVersions *int
	MaxDataVersions *int
	MinDataTTL      *int
	MaxDataTTL      *int
}

RetentionConfig stores dynamic table retention policy.

func DeleteDataAfterTTL

func DeleteDataAfterTTL(ttl time.Duration) RetentionConfig

DeleteDataAfterTTL is retention config that would remove versions after specified ttl.

func (RetentionConfig) FillAttrs

func (c RetentionConfig) FillAttrs(attrs map[string]any)

type Table

type Table struct {
	Schema     schema.Schema
	Attributes map[string]any
}

Jump to

Keyboard shortcuts

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