lib

package
v0.0.0-...-9cb3428 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildSchemaFunc

type BuildSchemaFunc func(ctx context.Context, psc PlanetScaleSource, schemaBuilder SchemaBuilder) error

type CanConnectFunc

type CanConnectFunc func(ctx context.Context, ps PlanetScaleSource) error

type ConnectClient

type ConnectClient interface {
	CanConnect(ctx context.Context, ps PlanetScaleSource) error
	Read(ctx context.Context, logger DatabaseLogger, ps PlanetScaleSource, tableName string, columns []string, lastKnownPosition *psdbconnect.TableCursor, onResult OnResult, onCursor OnCursor, onUpdate OnUpdate) (*SerializedCursor, error)
	ListShards(ctx context.Context, ps PlanetScaleSource) ([]string, error)
}

ConnectClient is a general purpose interface that defines all the data access methods needed for the PlanetScale Fivetran source to function.

func NewConnectClient

func NewConnectClient(mysqlAccess *MysqlClient) ConnectClient

func NewTestConnectClient

func NewTestConnectClient(r ReadFunc) ConnectClient

type DatabaseLogger

type DatabaseLogger interface {
	Info(string)
}

type GetVitessShardsFunc

type GetVitessShardsFunc func(ctx context.Context, psc PlanetScaleSource) ([]string, error)

type KeyspaceState

type KeyspaceState struct {
	Streams map[string]ShardStates `json:"streams"`
}

type ListShardsFunc

type ListShardsFunc func(ctx context.Context, ps PlanetScaleSource) ([]string, error)

type MysqlClient

type MysqlClient interface {
	BuildSchema(ctx context.Context, psc PlanetScaleSource, schemaBuilder SchemaBuilder) error
	PingContext(context.Context, PlanetScaleSource) error
	GetVitessShards(ctx context.Context, psc PlanetScaleSource) ([]string, error)
	Close() error
}

func NewMySQL

func NewMySQL(psc *PlanetScaleSource) (MysqlClient, error)

type MysqlColumn

type MysqlColumn struct {
	Name         string
	Type         string
	IsPrimaryKey bool
}

type OnCursor

type OnCursor func(*psdbconnect.TableCursor) error

type OnResult

type OnResult func(*sqltypes.Result, Operation) error

type OnUpdate

type OnUpdate func(*UpdatedRow) error

type Operation

type Operation int64
const (
	OpType_Insert Operation = iota
	OpType_Update
	OpType_Delete
	OpType_Truncate
)

type PingContextFunc

type PingContextFunc func(context.Context, PlanetScaleSource) error

type PlanetScaleSource

type PlanetScaleSource struct {
	Host                  string `json:"host"`
	Database              string `json:"database"`
	Username              string `json:"username"`
	Password              string `json:"password"`
	Shards                string `json:"shards"`
	TreatTinyIntAsBoolean bool   `json:"treat_tiny_int_as_boolean"`
	UseReplica            bool   `json:"use_replica"`
}

PlanetScaleSource defines a configured Fivetran Source for a PlanetScale database Consider this a connection string to a PlanetScale database.

func (PlanetScaleSource) DSN

DSN returns a DataSource that mysql libraries can use to connect to a PlanetScale database.

func (PlanetScaleSource) GetInitialState

func (psc PlanetScaleSource) GetInitialState(keyspaceOrDatabase string, shards []string) (ShardStates, error)

GetInitialState will return the initial/blank state for a given keyspace in all of its shards. This state can be round-tripped safely with Fivetran.

type ReadFunc

type ReadFunc func(ctx context.Context, logger DatabaseLogger, ps PlanetScaleSource, tableName string, columns []string, tc *psdbconnect.TableCursor, onResult OnResult, onCursor OnCursor, onUpdate OnUpdate) (*SerializedCursor, error)

type SchemaBuilder

type SchemaBuilder interface {
	OnKeyspace(keyspaceName string)
	OnTable(keyspaceName, tableName string)
	OnColumns(keyspaceName, tableName string, columns []MysqlColumn)
}

type SerializedCursor

type SerializedCursor struct {
	Cursor string `json:"cursor"`
}

func TableCursorToSerializedCursor

func TableCursorToSerializedCursor(cursor *psdbconnect.TableCursor) (*SerializedCursor, error)

func (SerializedCursor) SerializedCursorToTableCursor

func (s SerializedCursor) SerializedCursorToTableCursor() (*psdbconnect.TableCursor, error)

type ShardStates

type ShardStates struct {
	Shards map[string]*SerializedCursor `json:"shards"`
}

type SyncState

type SyncState struct {
	Keyspaces map[string]KeyspaceState `json:"keyspaces"`
}

type TestConnectClient

type TestConnectClient struct {
	ReadFn       ReadFunc
	CanConnectFn CanConnectFunc
	ListShardsFn ListShardsFunc
}

func (*TestConnectClient) CanConnect

func (tcc *TestConnectClient) CanConnect(ctx context.Context, ps PlanetScaleSource) error

func (*TestConnectClient) ListShards

func (tcc *TestConnectClient) ListShards(ctx context.Context, ps PlanetScaleSource) ([]string, error)

func (*TestConnectClient) Read

func (tcc *TestConnectClient) Read(ctx context.Context, logger DatabaseLogger, ps PlanetScaleSource, tableName string, columns []string, lastKnownPosition *psdbconnect.TableCursor, onResult OnResult, onCursor OnCursor, onUpdate OnUpdate) (*SerializedCursor, error)

type TestMysqlClient

type TestMysqlClient struct {
	BuildSchemaFn     BuildSchemaFunc
	PingContextFn     PingContextFunc
	GetVitessShardsFn GetVitessShardsFunc
}

func (TestMysqlClient) BuildSchema

func (t TestMysqlClient) BuildSchema(ctx context.Context, psc PlanetScaleSource, schemaBuilder SchemaBuilder) error

func (TestMysqlClient) Close

func (t TestMysqlClient) Close() error

func (TestMysqlClient) GetVitessShards

func (t TestMysqlClient) GetVitessShards(ctx context.Context, psc PlanetScaleSource) ([]string, error)

func (TestMysqlClient) PingContext

func (t TestMysqlClient) PingContext(ctx context.Context, source PlanetScaleSource) error

type UpdatedRow

type UpdatedRow struct {
	Before *sqltypes.Result
	After  *sqltypes.Result
}

Jump to

Keyboard shortcuts

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