github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/worker/utils.go (about) 1 // Copyright 2022 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package worker 15 16 import ( 17 "github.com/pingcap/tiflow/dm/config" 18 "github.com/pingcap/tiflow/dm/pb" 19 "github.com/pingcap/tiflow/dm/pkg/ha" 20 clientv3 "go.etcd.io/etcd/client/v3" 21 ) 22 23 func getExpectValidatorStage(cfg config.ValidatorConfig, etcdClient *clientv3.Client, source, task string, revision int64) (pb.Stage, error) { 24 // for subtask with validation mode=none, there is no validator stage, set to invalid 25 expectedValidatorStage := pb.Stage_InvalidStage 26 if cfg.Mode != config.ValidationNone { 27 validatorStageM, _, err := ha.GetValidatorStage(etcdClient, source, task, revision) 28 if err != nil { 29 return expectedValidatorStage, err 30 } 31 if s, ok := validatorStageM[task]; ok { 32 expectedValidatorStage = s.Expect 33 } 34 } 35 return expectedValidatorStage, nil 36 }