spanner

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ErrorCodeCreateClient = iota + 1
	ErrorCodeCloseClient
	ErrorCodeCreateDatabase
	ErrorCodeDropDatabase
	ErrorCodeTruncateAllTables
	ErrorCodeLoadSchema
	ErrorCodeUpdateDDL
	ErrorCodeUpdateDML
	ErrorCodeUpdatePartitionedDML
	ErrorCodeExecuteMigrations
	ErrorCodeGetMigrationVersion
	ErrorCodeSetMigrationVersion
	ErrorCodeNoMigration
	ErrorCodeMigrationVersionDirty
	ErrorCodeWaitOperation
	ErrorCodeCreateInstance
	ErrorCodeDeleteInstance
)

Variables

View Source
var (
	MigrationNameRegex = regexp.MustCompile(`[a-zA-Z0-9_\-]+`)
)

Functions

This section is empty.

Types

type AdminClient added in v1.1.0

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

func NewAdminClient added in v1.1.0

func NewAdminClient(ctx context.Context, config *Config) (*AdminClient, error)

func (*AdminClient) Close added in v1.1.0

func (c *AdminClient) Close() error

func (*AdminClient) CreateInstance added in v1.1.0

func (c *AdminClient) CreateInstance(ctx context.Context, node int32) error

func (*AdminClient) DeleteInstance added in v1.1.0

func (c *AdminClient) DeleteInstance(ctx context.Context, nmae string) error

type Client

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

func NewClient

func NewClient(ctx context.Context, config *Config) (*Client, error)

func (*Client) ApplyDDL

func (c *Client) ApplyDDL(ctx context.Context, statements []string) error

func (*Client) ApplyDDLFile

func (c *Client) ApplyDDLFile(ctx context.Context, filename string, ddl []byte) error

func (*Client) ApplyDML

func (c *Client) ApplyDML(ctx context.Context, statements []string, priority PriorityType) (int64, error)

func (*Client) ApplyDMLFile

func (c *Client) ApplyDMLFile(ctx context.Context, filename string, ddl []byte, partitioned bool, priority PriorityType) (int64, error)

func (*Client) ApplyPartitionedDML

func (c *Client) ApplyPartitionedDML(ctx context.Context, statements []string, priority PriorityType) (int64, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, filename string, ddl []byte) error

func (*Client) DropDatabase

func (c *Client) DropDatabase(ctx context.Context) error

func (*Client) EnsureMigrationTable

func (c *Client) EnsureMigrationTable(ctx context.Context, tableName string) error

func (*Client) ExecuteMigrations

func (c *Client) ExecuteMigrations(ctx context.Context, migrations Migrations, limit int, tableName string) error

func (*Client) GetSchemaMigrationVersion

func (c *Client) GetSchemaMigrationVersion(ctx context.Context, tableName string) (uint, bool, error)

func (*Client) LoadDDL

func (c *Client) LoadDDL(ctx context.Context) ([]byte, error)

func (*Client) SetSchemaMigrationVersion

func (c *Client) SetSchemaMigrationVersion(ctx context.Context, version uint, dirty bool, tableName string) error

func (*Client) TruncateAllTables added in v1.0.2

func (c *Client) TruncateAllTables(ctx context.Context) error

type Config

type Config struct {
	Project         string
	Instance        string
	Database        string
	CredentialsFile string

	// ClientOptions is options of Spanner clients when creating the clients for both normal
	// and admin. This options are evaluated first and can be overridden by other
	// configurations in Wrench.
	//
	// Experimental: There will be a breaking change in the future versions.
	ClientOptions []option.ClientOption
}

func (*Config) URL

func (c *Config) URL() string

type Error

type Error struct {
	Code ErrorCode
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int

type Migration

type Migration struct {
	// Version is the version of the migration
	Version uint

	// Name is the name of the migration
	Name string

	// Statements is the migration statements
	Statements []string
	// contains filtered or unexported fields
}

migration represents the parsed migration file. e.g. version_name.sql

type Migrations

type Migrations []*Migration

func LoadMigrations

func LoadMigrations(dir string) (Migrations, error)

func (Migrations) Len

func (ms Migrations) Len() int

func (Migrations) Less

func (ms Migrations) Less(i, j int) bool

func (Migrations) Swap

func (ms Migrations) Swap(i, j int)

type PriorityType added in v1.0.4

type PriorityType int
const (
	PriorityTypeUnspecified PriorityType = iota
	PriorityTypeHigh
	PriorityTypeMedium
	PriorityTypeLow
)

Jump to

Keyboard shortcuts

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