go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/schemamanager Index | Files | Directories

package schemamanager

import "gopkg.in/src-d/go-vitess.v1/vt/schemamanager"

Index

Package Files

local_controller.go plain_controller.go schemamanager.go tablet_executor.go ui_controller.go

Constants

const (
    // SchemaChangeDirName is the key name in the ControllerFactory params.
    // It specifies the schema change directory.
    SchemaChangeDirName = "schema_change_dir"
    // SchemaChangeUser is the key name in the ControllerFactory params.
    // It specifies the user who submits this schema change.
    SchemaChangeUser = "schema_change_user"
)

func RegisterControllerFactory Uses

func RegisterControllerFactory(name string, factory ControllerFactory)

RegisterControllerFactory register a control factory.

func Run Uses

func Run(ctx context.Context, controller Controller, executor Executor) error

Run applies schema changes on Vitess through VtGate.

type Controller Uses

type Controller interface {
    Open(ctx context.Context) error
    Read(ctx context.Context) (sqls []string, err error)
    Close()
    Keyspace() string
    OnReadSuccess(ctx context.Context) error
    OnReadFail(ctx context.Context, err error) error
    OnValidationSuccess(ctx context.Context) error
    OnValidationFail(ctx context.Context, err error) error
    OnExecutorComplete(ctx context.Context, result *ExecuteResult) error
}

Controller is responsible for getting schema change for a certain keyspace and also handling various events happened during schema change.

type ControllerFactory Uses

type ControllerFactory func(params map[string]string) (Controller, error)

ControllerFactory takes a set params and construct a Controller instance.

func GetControllerFactory Uses

func GetControllerFactory(name string) (ControllerFactory, error)

GetControllerFactory gets a ControllerFactory.

type ExecuteResult Uses

type ExecuteResult struct {
    FailedShards   []ShardWithError
    SuccessShards  []ShardResult
    CurSQLIndex    int
    Sqls           []string
    ExecutorErr    string
    TotalTimeSpent time.Duration
}

ExecuteResult contains information about schema management state

type Executor Uses

type Executor interface {
    Open(ctx context.Context, keyspace string) error
    Validate(ctx context.Context, sqls []string) error
    Execute(ctx context.Context, sqls []string) *ExecuteResult
    Close()
}

Executor applies schema changes to underlying system

type LocalController Uses

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

LocalController listens to the specified schema change dir and applies schema changes. schema change dir lay out

|
|----keyspace_01
     |----input
          |---- create_test_table.sql
          |---- alter_test_table_02.sql
          |---- ...
     |----complete // contains completed schema changes in yyyy/MM/dd
          |----2015
               |----01
                    |----01
                         |--- create_table_table_02.sql
     |----log // contains detailed execution information about schema changes
          |----2015
               |----01
                    |----01
                         |--- create_table_table_02.sql
     |----error // contains failed schema changes
          |----2015
               |----01
                    |----01
                         |--- create_table_table_03.sql

Schema Change Files: ${keyspace}/input/*.sql Error Files: ${keyspace}/error/${YYYY}/${MM}/${DD}/*.sql Log Files: ${keyspace}/log/${YYYY}/${MM}/${DD}/*.sql Complete Files: ${keyspace}/complete/${YYYY}/${MM}/${DD}/*.sql

func NewLocalController Uses

func NewLocalController(schemaChangeDir string) *LocalController

NewLocalController creates a new LocalController instance.

func (*LocalController) Close Uses

func (controller *LocalController) Close()

Close reset keyspace, sqlPath, errorDir, logDir and completeDir.

func (*LocalController) Keyspace Uses

func (controller *LocalController) Keyspace() string

Keyspace returns current keyspace that is ready for applying schema change.

func (*LocalController) OnExecutorComplete Uses

func (controller *LocalController) OnExecutorComplete(ctx context.Context, result *ExecuteResult) error

OnExecutorComplete is no-op

func (*LocalController) OnReadFail Uses

func (controller *LocalController) OnReadFail(ctx context.Context, err error) error

OnReadFail is no-op

func (*LocalController) OnReadSuccess Uses

func (controller *LocalController) OnReadSuccess(ctx context.Context) error

OnReadSuccess is no-op

func (*LocalController) OnValidationFail Uses

func (controller *LocalController) OnValidationFail(ctx context.Context, err error) error

OnValidationFail is no-op

func (*LocalController) OnValidationSuccess Uses

func (controller *LocalController) OnValidationSuccess(ctx context.Context) error

OnValidationSuccess is no-op

func (*LocalController) Open Uses

func (controller *LocalController) Open(ctx context.Context) error

Open goes through the schema change dir and find a keyspace with a pending schema change.

func (*LocalController) Read Uses

func (controller *LocalController) Read(ctx context.Context) ([]string, error)

Read reads schema changes.

type PlainController Uses

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

PlainController implements Controller interface.

func NewPlainController Uses

func NewPlainController(sqlStr string, keyspace string) *PlainController

NewPlainController creates a new PlainController instance.

func (*PlainController) Close Uses

func (controller *PlainController) Close()

Close is a no-op.

func (*PlainController) Keyspace Uses

func (controller *PlainController) Keyspace() string

Keyspace returns keyspace to apply schema.

func (*PlainController) OnExecutorComplete Uses

func (controller *PlainController) OnExecutorComplete(ctx context.Context, result *ExecuteResult) error

OnExecutorComplete is called when schemamanager finishes applying schema changes.

func (*PlainController) OnReadFail Uses

func (controller *PlainController) OnReadFail(ctx context.Context, err error) error

OnReadFail is called when schemamanager fails to read all sql statements.

func (*PlainController) OnReadSuccess Uses

func (controller *PlainController) OnReadSuccess(ctx context.Context) error

OnReadSuccess is called when schemamanager successfully reads all sql statements.

func (*PlainController) OnValidationFail Uses

func (controller *PlainController) OnValidationFail(ctx context.Context, err error) error

OnValidationFail is called when schemamanager fails to validate sql statements.

func (*PlainController) OnValidationSuccess Uses

func (controller *PlainController) OnValidationSuccess(ctx context.Context) error

OnValidationSuccess is called when schemamanager successfully validates all sql statements.

func (*PlainController) Open Uses

func (controller *PlainController) Open(ctx context.Context) error

Open is a no-op.

func (*PlainController) Read Uses

func (controller *PlainController) Read(ctx context.Context) ([]string, error)

Read reads schema changes

type ShardResult Uses

type ShardResult struct {
    Shard  string
    Result *querypb.QueryResult
    // Position is a replication position that is guaranteed to be after the
    // schema change was applied. It can be used to wait for slaves to receive
    // the schema change via replication.
    Position string
}

ShardResult contains sql execute information on a particular shard

type ShardWithError Uses

type ShardWithError struct {
    Shard string
    Err   string
}

ShardWithError contains information why a shard failed to execute given sql

type TabletExecutor Uses

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

TabletExecutor applies schema changes to all tablets.

func NewTabletExecutor Uses

func NewTabletExecutor(wr *wrangler.Wrangler, waitSlaveTimeout time.Duration) *TabletExecutor

NewTabletExecutor creates a new TabletExecutor instance

func (*TabletExecutor) AllowBigSchemaChange Uses

func (exec *TabletExecutor) AllowBigSchemaChange()

AllowBigSchemaChange changes TabletExecutor such that big schema changes will no longer be rejected.

func (*TabletExecutor) Close Uses

func (exec *TabletExecutor) Close()

Close clears tablet executor states

func (*TabletExecutor) DisallowBigSchemaChange Uses

func (exec *TabletExecutor) DisallowBigSchemaChange()

DisallowBigSchemaChange enables the check for big schema changes such that TabletExecutor will reject these.

func (*TabletExecutor) Execute Uses

func (exec *TabletExecutor) Execute(ctx context.Context, sqls []string) *ExecuteResult

Execute applies schema changes

func (*TabletExecutor) Open Uses

func (exec *TabletExecutor) Open(ctx context.Context, keyspace string) error

Open opens a connection to the master for every shard.

func (*TabletExecutor) Validate Uses

func (exec *TabletExecutor) Validate(ctx context.Context, sqls []string) error

Validate validates a list of sql statements.

type UIController Uses

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

UIController handles schema events.

func NewUIController Uses

func NewUIController(
    sqlStr string, keyspace string, writer http.ResponseWriter) *UIController

NewUIController creates a UIController instance

func (*UIController) Close Uses

func (controller *UIController) Close()

Close is a no-op.

func (*UIController) Keyspace Uses

func (controller *UIController) Keyspace() string

Keyspace returns keyspace to apply schema.

func (*UIController) OnExecutorComplete Uses

func (controller *UIController) OnExecutorComplete(ctx context.Context, result *ExecuteResult) error

OnExecutorComplete is no-op

func (*UIController) OnReadFail Uses

func (controller *UIController) OnReadFail(ctx context.Context, err error) error

OnReadFail is no-op

func (*UIController) OnReadSuccess Uses

func (controller *UIController) OnReadSuccess(ctx context.Context) error

OnReadSuccess is no-op

func (*UIController) OnValidationFail Uses

func (controller *UIController) OnValidationFail(ctx context.Context, err error) error

OnValidationFail is no-op

func (*UIController) OnValidationSuccess Uses

func (controller *UIController) OnValidationSuccess(ctx context.Context) error

OnValidationSuccess is no-op

func (*UIController) Open Uses

func (controller *UIController) Open(ctx context.Context) error

Open is a no-op.

func (*UIController) Read Uses

func (controller *UIController) Read(ctx context.Context) ([]string, error)

Read reads schema changes

Directories

PathSynopsis
schemaswap

Package schemamanager imports 16 packages (graph) and is imported by 4 packages. Updated 2019-06-13. Refresh now. Tools for package owners.