MCPcopy
hub / github.com/go-sql-driver/mysql / watchCancel

Method watchCancel

connection.go:720–743  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

718}
719
720func (mc *mysqlConn) watchCancel(ctx context.Context) error {
721 if mc.watching {
722 // Reach here if canceled,
723 // so the connection is already invalid
724 mc.cleanup()
725 return nil
726 }
727 // When ctx is already cancelled, don't watch it.
728 if err := ctx.Err(); err != nil {
729 return err
730 }
731 // When ctx is not cancellable, don't watch it.
732 if ctx.Done() == nil {
733 return nil
734 }
735 // When watcher is not alive, can't watch it.
736 if mc.watcher == nil {
737 return nil
738 }
739
740 mc.watching = true
741 mc.watcher <- ctx
742 return nil
743}
744
745func (mc *mysqlConn) startWatcher() {
746 watcher := make(chan context.Context, 1)

Callers 8

ConnectMethod · 0.95
PingMethod · 0.95
BeginTxMethod · 0.95
QueryContextMethod · 0.95
ExecContextMethod · 0.95
PrepareContextMethod · 0.95
QueryContextMethod · 0.80
ExecContextMethod · 0.80

Calls 1

cleanupMethod · 0.95

Tested by

no test coverage detected