Documentation ¶
Index ¶
- func StartRead(ctx context.Context, reader BatchReader, sender plugin.RecordSender) (err error)
- type BaseBatchReader
- func (b *BaseBatchReader) JobID() int64
- func (b *BaseBatchReader) Parameter() database.Parameter
- func (b *BaseBatchReader) Read(ctx context.Context, param database.Parameter, handler database.FetchHandler) (err error)
- func (b *BaseBatchReader) TaskGroupID() int64
- func (b *BaseBatchReader) TaskID() int64
- type BaseColumn
- type BaseConfig
- func (b *BaseConfig) GetBaseTable() *database.BaseTable
- func (b *BaseConfig) GetColumns() (columns []Column)
- func (b *BaseConfig) GetPassword() string
- func (b *BaseConfig) GetQuerySQL() []string
- func (b *BaseConfig) GetSplitConfig() SplitConfig
- func (b *BaseConfig) GetURL() string
- func (b *BaseConfig) GetUsername() string
- func (b *BaseConfig) GetWhere() string
- type BaseDbHandler
- func (d *BaseDbHandler) Config(conf *config.JSON) (Config, error)
- func (d *BaseDbHandler) MaxParam(config Config, table database.Table) database.Parameter
- func (d *BaseDbHandler) MinParam(config Config, table database.Table) database.Parameter
- func (d *BaseDbHandler) Querier(name string, conf *config.JSON) (Querier, error)
- func (d *BaseDbHandler) SplitParam(config Config, querier Querier) database.Parameter
- func (d *BaseDbHandler) TableParam(config Config, querier Querier) database.Parameter
- type BatchReader
- type Column
- type Config
- type ConnConfig
- type DbHandler
- type Job
- type MaxParam
- type MinParam
- type Querier
- type QueryParam
- type SplitConfig
- type SplitParam
- type SplitRange
- type TableConfig
- type TableParam
- type TableParamConfig
- type TableParamTable
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartRead ¶
func StartRead(ctx context.Context, reader BatchReader, sender plugin.RecordSender) (err error)
StartRead Start reading
Types ¶
type BaseBatchReader ¶
type BaseBatchReader struct {
// contains filtered or unexported fields
}
BaseBatchReader Basic batch reader
func NewBaseBatchReader ¶
func NewBaseBatchReader(task *Task, mode string, opts *sql.TxOptions) *BaseBatchReader
NewBaseBatchReader Get basic batch reader through task, query mode, and transaction options
func (*BaseBatchReader) Parameter ¶
func (b *BaseBatchReader) Parameter() database.Parameter
Parameter Query parameters
func (*BaseBatchReader) Read ¶
func (b *BaseBatchReader) Read(ctx context.Context, param database.Parameter, handler database.FetchHandler) (err error)
Query through context ctx, description, and database handler
func (*BaseBatchReader) TaskGroupID ¶
func (b *BaseBatchReader) TaskGroupID() int64
TaskGroupID Task group number
type BaseColumn ¶
type BaseColumn struct {
Name string
}
BaseColumn represents basic column information.
func (*BaseColumn) GetName ¶
func (b *BaseColumn) GetName() string
GetName retrieves the column name.
type BaseConfig ¶
type BaseConfig struct { Username string `json:"username"` // Username is the user's name. Password string `json:"password"` // Password is the user's password. Column []string `json:"column"` // Columns is the list of column information. Connection ConnConfig `json:"connection"` // ConnectionInfo is the database connection information. Where string `json:"where"` // Where is the query condition. Split SplitConfig `json:"split"` // SplitKey is the key used for splitting. QuerySQL []string `json:"querySql"` // QuerySQL is the SQL query. }
BaseConfig represents the basic configuration for a relational data reader.
func NewBaseConfig ¶
func NewBaseConfig(conf *config.JSON) (c *BaseConfig, err error)
NewBaseConfig creates a new instance of BaseConfig based on the provided JSON configuration conf.
func (*BaseConfig) GetBaseTable ¶
func (b *BaseConfig) GetBaseTable() *database.BaseTable
GetBaseTable retrieves the table information.
func (*BaseConfig) GetColumns ¶
func (b *BaseConfig) GetColumns() (columns []Column)
GetColumns retrieves the column information.
func (*BaseConfig) GetPassword ¶
func (b *BaseConfig) GetPassword() string
GetPassword retrieves the password.
func (*BaseConfig) GetQuerySQL ¶ added in v0.1.4
func (b *BaseConfig) GetQuerySQL() []string
GetQuerySQL retrieves the SQL query.
func (*BaseConfig) GetSplitConfig ¶
func (b *BaseConfig) GetSplitConfig() SplitConfig
GetSplitConfig retrieves the splitting configuration.
func (*BaseConfig) GetURL ¶
func (b *BaseConfig) GetURL() string
GetURL retrieves the URL for connecting to the relational database.
func (*BaseConfig) GetUsername ¶
func (b *BaseConfig) GetUsername() string
GetUsername retrieves the username.
func (*BaseConfig) GetWhere ¶
func (b *BaseConfig) GetWhere() string
GetWhere retrieves the query conditions.
type BaseDbHandler ¶
type BaseDbHandler struct {
// contains filtered or unexported fields
}
BaseDbHandler - Basic Database Handler
func NewBaseDbHandler ¶
func NewBaseDbHandler(newQuerier func(name string, conf *config.JSON) (Querier, error), opts *sql.TxOptions) *BaseDbHandler
Create a new instance of the BasicDbHandler using the function to obtain a querier (newQuerier) and transaction options (opts)
func (*BaseDbHandler) Config ¶
func (d *BaseDbHandler) Config(conf *config.JSON) (Config, error)
Config - Retrieve the relational database input configuration using the JSON configuration (conf)
func (*BaseDbHandler) MaxParam ¶
MaxParam - Get the maximum split value parameter based on the relational database input configuration (config) and table querier (Table)
func (*BaseDbHandler) MinParam ¶
MinParam - Retrieve split table parameters using the relational database input configuration (config) and querier
func (*BaseDbHandler) Querier ¶
Querier - Acquire a querier based on the database name (name) and JSON configuration (conf)
func (*BaseDbHandler) SplitParam ¶
func (d *BaseDbHandler) SplitParam(config Config, querier Querier) database.Parameter
SplitParam - Obtain the minimum split value parameter based on the relational database input configuration (config) and table (Table)
func (*BaseDbHandler) TableParam ¶
func (d *BaseDbHandler) TableParam(config Config, querier Querier) database.Parameter
TableParam - Get table parameters using the relational database input configuration (config) and querier
type BatchReader ¶
type BatchReader interface { JobID() int64 // Job number TaskGroupID() int64 // Task group number TaskID() int64 // Task number Read(ctx context.Context, param database.Parameter, handler database.FetchHandler) (err error) // Query through context ctx, description, and database handler Parameter() database.Parameter // Query parameters }
BatchReader Batch reader
type Column ¶
type Column interface {
GetName() string // GetTableName retrieves the table name.
}
Column represents column information.
type Config ¶
type Config interface { GetUsername() string // GetUsername retrieves the username. GetPassword() string // GetPassword retrieves the password. GetURL() string // GetURL retrieves the connection URL. GetColumns() []Column // GetColumns retrieves the column information. GetBaseTable() *database.BaseTable // GetBaseTable retrieves the table information. GetWhere() string // GetWhere retrieves the query conditions. GetSplitConfig() SplitConfig // GetSplitConfig retrieves the splitting configuration. GetQuerySQL() []string // GetQuerySQL retrieves the query SQL. }
Config represents the configuration for a relational data reader.
type ConnConfig ¶
type ConnConfig struct { URL string `json:"url"` // ConnectToDatabase establishes a connection to the database. Table TableConfig `json:"table"` // TableConfig represents the configuration for a table. }
ConnConfig represents the configuration for connecting to a database.
type DbHandler ¶
type DbHandler interface { Querier(name string, conf *config.JSON) (Querier, error) // Obtain a querier based on the database name (name) and JSON configuration (conf) Config(conf *config.JSON) (Config, error) // Acquire the relational database input configuration using the JSON configuration (conf) TableParam(config Config, querier Querier) database.Parameter // Retrieve table parameters using the relational database input configuration (config) and querier SplitParam(config Config, querier Querier) database.Parameter // Obtain split table parameters using the relational database input configuration (config) and querier MinParam(config Config, table database.Table) database.Parameter // Get the minimum split value parameter based on the relational database input configuration (config) and table (Table) MaxParam(config Config, table database.Table) database.Parameter // Retrieve the maximum split value parameter using the relational database input configuration (config) and table querier (Table) }
DbHandler - Database Handler
type Job ¶
type Job struct { *plugin.BaseJob Querier Querier Config Config // contains filtered or unexported fields }
Job
type MaxParam ¶
MaxParam Maximum value parameter
func NewMaxParam ¶
NewMaxParam Get query parameters through relational database input configuration config, corresponding database table table, and transaction options opts
type MinParam ¶
MinParam Minimum value parameter
func NewMinParam ¶
NewMinParam Get the minimum value parameter through relational database input configuration config, corresponding database table table, and transaction options opts
type Querier ¶
type Querier interface { // Obtain a specific table based on basic table information. Table(*database.BaseTable) database.Table // Check connectivity. PingContext(ctx context.Context) error // Perform a query using the specified query statement. QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) // Obtain a specific table based on the provided parameters. FetchTableWithParam(ctx context.Context, param database.Parameter) (database.Table, error) // Retrieve records using the provided parameters and the handler. FetchRecord(ctx context.Context, param database.Parameter, handler database.FetchHandler) (err error) // Retrieve records using the provided parameters, the handler, and within a transaction. FetchRecordWithTx(ctx context.Context, param database.Parameter, handler database.FetchHandler) (err error) // Close resources. Close() error }
Querier - Query Executor
type QueryParam ¶
QueryParam Query parameters
func NewQueryParam ¶
NewQueryParam Get query parameters through relational database input configuration config, corresponding database table table, and transaction options opts
type SplitConfig ¶
type SplitConfig struct { Key string `json:"key"` // Splitting Key // day (Day), min (Minute), s (Second), ms (Millisecond), us (Microsecond), ns (Nanosecond) TimeAccuracy string `json:"timeAccuracy"` // Splitting Time Precision (Default: day) Range SplitRange `json:"range"` // Splitting Range }
SplitConfig - Splitting Configuration
type SplitParam ¶
SplitParam Splitting parameters
func NewSplitParam ¶
func NewSplitParam(config Config, table TableParamTable, opts *sql.TxOptions) *SplitParam
NewSplitParam Get table parameter configuration config, get split table parameters through table parameters of the corresponding database table and transaction options opts
type SplitRange ¶
type SplitRange struct { Type string `json:"type"` // Type: bigint, string, time Layout string `json:"layout"` // Time Format Left string `json:"left"` // Start Point Right string `json:"right"` // End Point // contains filtered or unexported fields }
SplitRange - Splitting Range Configuration
type TableConfig ¶
type TableConfig struct { Db string `json:"db"` // Database is the name of the database. Schema string `json:"schema"` // Schema is the schema name. Name string `json:"name"` // TableName is the name of the table. }
TableConfig represents the configuration for a table.
type TableParam ¶
type TableParam struct { *database.BaseParam Config TableParamConfig }
TableParam Table parameters
func NewTableParam ¶
func NewTableParam(config TableParamConfig, table TableParamTable, opts *sql.TxOptions) *TableParam
NewTableParam Get table parameter configuration config, get table parameters through table parameters of the corresponding database table and transaction options opts
type TableParamConfig ¶
type TableParamConfig interface { GetColumns() []Column // Get column information GetBaseTable() *database.BaseTable // Get table information }
TableParamConfig Table parameter configuration
type TableParamTable ¶
type TableParamTable interface {
Table(*database.BaseTable) database.Table // Get the table of the corresponding database through table parameters
}
TableParamTable Get the table of the corresponding database through table parameters