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

Method Shutdown

driver/mysql/extractor.go:1561–1615  ·  view source on GitHub ↗

Shutdown is used to tear down the extractor

()

Source from the content-addressed store, hash-verified

1559}
1560// Shutdown is used to tear down the extractor
1561func (e *Extractor) Shutdown() error {
1562 e.logger.Debug("extractor shutdown")
1563 e.shutdownLock.Lock()
1564 defer e.shutdownLock.Unlock()
1565
1566 if e.shutdown {
1567 return nil
1568 }
1569 e.logger.Info("extractor shutdown")
1570
1571 e.shutdown = true
1572 close(e.shutdownCh)
1573
1574 if e.RevApplier != nil {
1575 err := e.RevApplier.Shutdown()
1576 if err != nil {
1577 e.logger.Info("error RevApplier.Shutdown", "err", err)
1578 }
1579 }
1580
1581 if e.binlogReader != nil && atomic.LoadInt32(&e.binlogReader.BigTxCount) >= 1 {
1582 g.SubBigTxJob()
1583 }
1584
1585 if e.natsConn != nil {
1586 e.natsConn.Close()
1587 }
1588
1589 for _, d := range e.dumpers {
1590 d.Close()
1591 }
1592
1593 if err := sql.CloseDB(e.singletonDB); err != nil {
1594 e.logger.Error("Shutdown error close singletonDB.", "err", err)
1595 }
1596
1597 if e.inspector != nil {
1598 e.inspector.Close()
1599 }
1600
1601 if e.binlogReader != nil {
1602 if err := e.binlogReader.Close(); err != nil {
1603 e.logger.Error("Shutdown error close binlogReader.", "err", err)
1604 }
1605 }
1606
1607 e.wg.Wait()
1608
1609 if err := sql.CloseDB(e.db); err != nil {
1610 e.logger.Error("Shutdown error close e.db.", "err", err)
1611 }
1612
1613 e.logger.Info("Shutting down")
1614 return nil
1615}
1616
1617func (e *Extractor) sendFullComplete() (err error) {
1618 dumpMsg, err := common.Encode(&common.DumpStatResult{

Callers 2

RunMethod · 0.95
onErrorMethod · 0.95

Calls 4

SubBigTxJobFunction · 0.92
CloseDBFunction · 0.92
ShutdownMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected