datasource

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2018 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertGenericColumnValueToSpannerValue

func ConvertGenericColumnValueToSpannerValue(cv *GenericColumnValue) (interface{}, error)

ConvertGenericColumnValueToSpannerValue converts GenericColumnValue to Spanner Value

Types

type CSVDatasource

type CSVDatasource struct {
	RootPath       string `json:"root_path"`
	ColumnRowIndex int    `json:"column_row_index"`
}

CSVDatasource is datasource config for csv file

func NewCSVDatasource

func NewCSVDatasource(rootPath string, columnRowIndex int) (*CSVDatasource, error)

NewCSVDatasource is create CSVDatasource instance

func (*CSVDatasource) GetRows

func (ds *CSVDatasource) GetRows(ctx context.Context, schema *Schema) ([]*Row, error)

GetRows is getting rows from csv file

func (*CSVDatasource) GetSchema

func (ds *CSVDatasource) GetSchema(ctx context.Context, name string) (*Schema, error)

GetSchema is getting schema from csv file

func (*CSVDatasource) SetRows

func (ds *CSVDatasource) SetRows(ctx context.Context, schema *Schema, rows []*Row) error

SetRows is setting rows to csv file

func (*CSVDatasource) SetSchema

func (ds *CSVDatasource) SetSchema(ctx context.Context, schema *Schema) error

SetSchema is setting schema to csv file

type Column

type Column struct {
	Name            string     `json:"name"`
	OrdinalPosition int        `json:"ordinal_position"`
	Type            ColumnType `json:"type"`
	NotNull         bool       `json:"not_null"`
	AutoIncrement   bool       `json:"auto_increment"`
}

func ScanSchemaColumn

func ScanSchemaColumn(row *spanner.Row) (*Column, error)

func (*Column) IsArrayType

func (c *Column) IsArrayType() bool

func (*Column) String

func (c *Column) String() string

type ColumnType

type ColumnType int
const (
	ColumnTypeNull ColumnType = iota
	ColumnTypeString
	ColumnTypeInt
	ColumnTypeFloat
	ColumnTypeDatetime
	ColumnTypeDate
	ColumnTypeBytes
	ColumnTypeBool
	ColumnTypeStringArray
	ColumnTypeIntArray
	ColumnTypeFloatArray
	ColumnTypeDatetimeArray
	ColumnTypeDateArray
	ColumnTypeBytesArray
	ColumnTypeBoolArray
)

func (ColumnType) String

func (ct ColumnType) String() string

type Datasource

type Datasource interface {
	GetSchema(ctx context.Context, name string) (*Schema, error)
	SetSchema(ctx context.Context, sc *Schema) error
	GetRows(ctx context.Context, sc *Schema) ([]*Row, error)
	SetRows(ctx context.Context, sc *Schema, rows []*Row) error
}

type GenericColumnValue

type GenericColumnValue struct {
	Column *Column
	Value  interface{}
}

TOOD: rename GenericRowValue?

func GenericSpannerValueToTamateGenericColumnValue

func GenericSpannerValueToTamateGenericColumnValue(sp spanner.GenericColumnValue, col *Column) (*GenericColumnValue, error)

func NewGenericColumnValue

func NewGenericColumnValue(col *Column) *GenericColumnValue

func NewStringGenericColumnValue

func NewStringGenericColumnValue(col *Column, s string) *GenericColumnValue

func (*GenericColumnValue) BoolValue

func (cv *GenericColumnValue) BoolValue() bool

func (*GenericColumnValue) StringValue

func (cv *GenericColumnValue) StringValue() string

func (*GenericColumnValue) TimeValue

func (cv *GenericColumnValue) TimeValue() (time.Time, error)

type GroupByKey

type GroupByKey map[string][]*GenericColumnValue

type Key

type Key struct {
	KeyType     KeyType  `json:"key_type"`
	ColumnNames []string `json:"column_names"`
}

func (*Key) String

func (k *Key) String() string

type KeyType

type KeyType int
const (
	KeyTypePrimary KeyType = iota
	KeyTypeUnique
	KeyTypeIndex
)

type MockDatasource

type MockDatasource struct{}

func NewMockDatasource

func NewMockDatasource() (*MockDatasource, error)

func (*MockDatasource) GetAllSchema

func (ds *MockDatasource) GetAllSchema(ctx context.Context) ([]*Schema, error)

func (*MockDatasource) GetRows

func (ds *MockDatasource) GetRows(ctx context.Context, sc *Schema) ([]*Row, error)

func (*MockDatasource) GetSchema

func (ds *MockDatasource) GetSchema(ctx context.Context, name string) (*Schema, error)

func (*MockDatasource) SetRows

func (ds *MockDatasource) SetRows(ctx context.Context, sc *Schema, rows []*Row) error

func (*MockDatasource) SetSchema

func (ds *MockDatasource) SetSchema(ctx context.Context, sc *Schema) error

type MySQLDatasource

type MySQLDatasource struct {
	DSN string `json:"dsn"`
	// contains filtered or unexported fields
}

MySQLDatasource is datasource config for MySQL DB

func NewMySQLDatasource

func NewMySQLDatasource(dsn string) (*MySQLDatasource, error)

NewMySQLDatasource is create MySQLDatasource instance

func (*MySQLDatasource) Close

func (ds *MySQLDatasource) Close() error

Close is close connection

func (*MySQLDatasource) GetRows

func (ds *MySQLDatasource) GetRows(ctx context.Context, schema *Schema) ([]*Row, error)

GetRows is getting rows from MySQL DB

func (*MySQLDatasource) GetSchema

func (ds *MySQLDatasource) GetSchema(ctx context.Context, name string) (*Schema, error)

GetSchema is getting schema from MySQL DB

func (*MySQLDatasource) Open

func (ds *MySQLDatasource) Open() error

Open is open connection

func (*MySQLDatasource) SetRows

func (ds *MySQLDatasource) SetRows(ctx context.Context, schema *Schema, rows []*Row) error

SetRows is setting rows to MySQL DB

func (*MySQLDatasource) SetSchema

func (ds *MySQLDatasource) SetSchema(ctx context.Context, schema *Schema) error

SetSchema is setting schema to MySQL DB

type Row

type Row struct {
	GroupByKey GroupByKey `json:"-"`
	Values     RowValues
}

func (*Row) String

func (r *Row) String() string

type RowValues

type RowValues map[string]*GenericColumnValue

type Schema

type Schema struct {
	Name       string    `json:"name"`
	PrimaryKey *Key      `json:"primary_key"`
	Columns    []*Column `json:"columns"`
}

* Schema

func (*Schema) GetColumnNames

func (sc *Schema) GetColumnNames() []string

GetColumnNames is return name list of columns

func (*Schema) String

func (sc *Schema) String() string

type SpannerDatasource

type SpannerDatasource struct {
	DSN string `json:"dsn"`
	// contains filtered or unexported fields
}

func NewSpannerDatasource

func NewSpannerDatasource(dsn string) (*SpannerDatasource, error)

func (*SpannerDatasource) Close

func (ds *SpannerDatasource) Close() error

func (*SpannerDatasource) GetAllSchema

func (ds *SpannerDatasource) GetAllSchema(ctx context.Context) ([]*Schema, error)

func (*SpannerDatasource) GetRows

func (ds *SpannerDatasource) GetRows(ctx context.Context, schema *Schema) ([]*Row, error)

GetRows is get rows method

func (*SpannerDatasource) GetSchema

func (ds *SpannerDatasource) GetSchema(ctx context.Context, name string) (*Schema, error)

GetSchema is get schema method

func (*SpannerDatasource) SetRows

func (ds *SpannerDatasource) SetRows(ctx context.Context, schema *Schema, rows []*Row) error

SetRows is set rows method

func (*SpannerDatasource) SetSchema

func (ds *SpannerDatasource) SetSchema(ctx context.Context, schema *Schema) error

SetSchema is set schema method

type SpreadsheetDatasource

type SpreadsheetDatasource struct {
	SpreadsheetID  string `json:"spreadsheet_id"`
	ColumnRowIndex int    `json:"column_row_index"`
	// contains filtered or unexported fields
}

func NewGoogleSpreadsheetDatasource

func NewGoogleSpreadsheetDatasource(client *http.Client, spreadsheetID string, columnRowIndex int) (*SpreadsheetDatasource, error)

NewGoogleSpreadsheetDatasource is return SpreadsheetDatasource for google instance

func NewSpreadsheetDatasource

func NewSpreadsheetDatasource(service SpreadsheetService, spreadsheetID string, columnRowIndex int) (*SpreadsheetDatasource, error)

NewSpreadsheetDatasource is return SpreadsheetDatasource instance

func (*SpreadsheetDatasource) GetRows

func (ds *SpreadsheetDatasource) GetRows(ctx context.Context, schema *Schema) ([]*Row, error)

GetRows is getting rows from spreadsheet

func (*SpreadsheetDatasource) GetSchema

func (ds *SpreadsheetDatasource) GetSchema(ctx context.Context, name string) (*Schema, error)

GetSchema is getting schema from spreadsheet

func (*SpreadsheetDatasource) SetRows

func (ds *SpreadsheetDatasource) SetRows(ctx context.Context, schema *Schema, rows []*Row) error

SetRows is set rows method

func (*SpreadsheetDatasource) SetSchema

func (ds *SpreadsheetDatasource) SetSchema(ctx context.Context, schema *Schema) error

SetSchema is set schema method

type SpreadsheetService

type SpreadsheetService interface {
	Get(ctx context.Context, spreadsheetID string, sheetName string) ([][]interface{}, error)
}

Jump to

Keyboard shortcuts

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