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

Method Run

driver/mysql/extractor.go:152–367  ·  view source on GitHub ↗

Run executes the complete extract logic.

()

Source from the content-addressed store, hash-verified

150
151// Run executes the complete extract logic.
152func (e *Extractor) Run() {
153 var err error
154
155 {
156 jobStatus, _ := e.storeManager.GetJobStatus(e.subject)
157 if jobStatus == common.TargetGtidFinished {
158 _ = e.Shutdown()
159 return
160 }
161 }
162
163 {
164 target, err := e.storeManager.GetTargetGtid(e.subject)
165 if err != nil {
166 e.onError(common.TaskStateDead, err)
167 return
168 }
169 e.targetGtid = target
170
171 }
172
173 if e.mysqlContext.WaitOnJob != "" {
174 jobStatus, err := e.storeManager.GetJobStatus(e.subject)
175 if err != nil {
176 e.onError(common.TaskStateDead, err)
177 return
178 }
179 // ensure job status exist when first time to start a reverse task
180 if jobStatus == "" {
181 jobStatus = common.DtleJobStatusReverseInit
182 e.storeManager.SaveJobInfo(common.JobListItemV2{JobId: e.subject, JobStatus: jobStatus})
183 }
184 firstWait := jobStatus == common.DtleJobStatusReverseInit
185 if firstWait {
186 // the first time to wait
187 e.logger.Info("waiting for another job to finish", "job2", e.mysqlContext.WaitOnJob)
188 err = e.storeManager.WaitOnJob(e.subject, e.mysqlContext.WaitOnJob, e.shutdownCh)
189 if err != nil {
190 e.onError(common.TaskStateDead, err)
191 return
192 }
193 }
194 e.logger.Info("after WaitOnJob", "job2", e.mysqlContext.WaitOnJob, "firstWait", firstWait)
195 }
196
197 // PutConfig before WatchNats
198 err = e.storeManager.PutConfig(e.subject, e.mysqlContext)
199 if err != nil {
200 e.onError(common.TaskStateDead, errors.Wrap(err, "PutConfig"))
201 return
202 }
203
204 e.natsAddr, err = e.storeManager.SrcWatchNats(e.subject, e.shutdownCh, func(err error) {
205 e.onError(common.TaskStateDead, err)
206 })
207 if err != nil {
208 e.onError(common.TaskStateDead, errors.Wrap(err, "SrcWatchNats"))
209 return

Callers

nothing calls this directly

Calls 15

ShutdownMethod · 0.95
onErrorMethod · 0.95
initiateInspectorMethod · 0.95
initNatsPubClientMethod · 0.95
initDBConnectionsMethod · 0.95
sendSysVarAndSqlModeMethod · 0.95
initBinlogReaderMethod · 0.95
mysqlDumpMethod · 0.95
sendFullCompleteMethod · 0.95

Tested by

no test coverage detected