MCPcopy Create free account
hub / github.com/actiontech/dtle / verifyDriverConfig

Method verifyDriverConfig

driver/driver.go:617–672  ·  view source on GitHub ↗
(config common.DtleTaskConfig)

Source from the content-addressed store, hash-verified

615}
616
617func (d *Driver) verifyDriverConfig(config common.DtleTaskConfig) error {
618 errMsgs := []string{}
619 addErrMsgs := func(msg string) {
620 errMsgs = append(errMsgs, fmt.Sprintf(" * %v", msg))
621 }
622
623 if !(1 <= config.BulkInsert1 && config.BulkInsert1 <= config.BulkInsert2) {
624 return fmt.Errorf("expect 1 <= BulkInsert1 <= BulkInsert2. %v %v", config.BulkInsert1, config.BulkInsert2)
625 }
626
627 for _, doDb := range config.ReplicateDoDb {
628 if doDb.TableSchema == "" && doDb.TableSchemaRegex == "" {
629 addErrMsgs("TableSchema and TableSchemaRegex in ReplicateDoDb cannot both be blank")
630 }
631 if doDb.TableSchema != "" && doDb.TableSchemaRegex != "" {
632 addErrMsgs(fmt.Sprintf("TableSchema and TableSchemaRegex in ReplicateDoDb cannot both be used. TableSchema=%v, TableSchemaRegex=%v", doDb.TableSchema, doDb.TableSchemaRegex))
633 }
634 if doDb.TableSchemaRegex != "" && doDb.TableSchemaRename == "" {
635 addErrMsgs(fmt.Sprintf("TableSchemaRename in ReplicateDoDb is required while using TableSchemaRegex in ReplicateDoDb. TableSchemaRegex=%v", doDb.TableSchemaRegex))
636 }
637
638 for _, doTb := range doDb.Tables {
639 if len(doTb.ColumnMapTo) != 0 {
640 if len(doTb.ColumnMapTo) != len(doTb.ColumnMapFrom) {
641 addErrMsgs("ColumnMapTo should be either empty or the same cardinality as ColumnMapFrom")
642 }
643 }
644 if doTb.TableName == "" && doTb.TableRegex == "" {
645 addErrMsgs("TableName and TableRegex in ReplicateDoDb cannot both be empty")
646 }
647 if doTb.TableName != "" && doTb.TableRegex != "" {
648 addErrMsgs(fmt.Sprintf("TableName and TableRegex in ReplicateDoDb cannot both be used. TableSchema=%v, TableName=%v, TableRegex=%v", doDb.TableSchema, doTb.TableName, doTb.TableRegex))
649 }
650 if doTb.TableRegex != "" && doTb.TableRename == "" {
651 addErrMsgs(fmt.Sprintf("TableRename in ReplicateDoDb is required while using TableRegex in ReplicateDoDb. TableSchema=%v, TableRegex=%v", doDb.TableSchema, doTb.TableRegex))
652 }
653 }
654 }
655
656 for _, db := range config.ReplicateIgnoreDb {
657 if db.TableSchema == "" {
658 addErrMsgs("TableSchema in ReplicateIgnoreDb should not be empty")
659 }
660 for _, tb := range db.Tables {
661 if tb.TableName == "" {
662 addErrMsgs(fmt.Sprintf("TableName in ReplicateIgnoreDb should not be empty. TableSchema=%v", db.TableSchema))
663 }
664 }
665 }
666
667 if len(errMsgs) > 0 {
668 return fmt.Errorf("\n%v", strings.Join(errMsgs, "\n"))
669 } else {
670 return nil
671 }
672}
673
674func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) {

Callers 1

StartTaskMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected