(m *mysqlProxy)
| 68 | } |
| 69 | |
| 70 | func asyncSQL(m *mysqlProxy) { |
| 71 | utils.GoWithRecover(func() { |
| 72 | adminTxConn := make(map[string]*client.Conn) |
| 73 | readonlyTxConn := make(map[string]*client.Conn) |
| 74 | |
| 75 | for { |
| 76 | select { |
| 77 | case <-m.ctx.Done(): |
| 78 | p2pChans.adminPubSub.Exit() |
| 79 | p2pChans.readonlyPubSub.Exit() |
| 80 | _ = p2pChans.adminHost.Host.Close() |
| 81 | _ = p2pChans.adminHost.KadDHT.Close() |
| 82 | _ = p2pChans.readonlyHost.Host.Close() |
| 83 | _ = p2pChans.readonlyHost.KadDHT.Close() |
| 84 | return |
| 85 | |
| 86 | // Handle admin channel messages |
| 87 | case msg := <-p2pChans.adminPubSub.Inbound: |
| 88 | s := &p2p.Message{ |
| 89 | SenderID: msg.GetFrom(), |
| 90 | Content: string(msg.GetData()), |
| 91 | } |
| 92 | handleInboundSQL(m, s, adminTxConn, "admin") |
| 93 | |
| 94 | // Handle readonly channel messages |
| 95 | case msg := <-p2pChans.readonlyPubSub.Inbound: |
| 96 | s := &p2p.Message{ |
| 97 | SenderID: msg.GetFrom(), |
| 98 | Content: string(msg.GetData()), |
| 99 | } |
| 100 | handleInboundSQL(m, s, readonlyTxConn, "readonly") |
| 101 | } |
| 102 | } |
| 103 | }, func(r any) { |
| 104 | time.Sleep(time.Second) |
| 105 | asyncSQL(m) |
| 106 | }) |
| 107 | } |
| 108 | |
| 109 | func handleInboundSQL(m *mysqlProxy, s *p2p.Message, txConn map[string]*client.Conn, accessType string) { |
| 110 | var err error |
no test coverage detected