MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / asyncSQL

Function asyncSQL

IceFireDB-SQLProxy/internal/mysql/p2p.go:70–107  ·  view source on GitHub ↗
(m *mysqlProxy)

Source from the content-addressed store, hash-verified

68}
69
70func 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
109func handleInboundSQL(m *mysqlProxy, s *p2p.Message, txConn map[string]*client.Conn, accessType string) {
110 var err error

Callers 1

initP2PFunction · 0.70

Calls 7

GoWithRecoverFunction · 0.92
handleInboundSQLFunction · 0.85
DoneMethod · 0.80
GetFromMethod · 0.80
GetDataMethod · 0.80
CloseMethod · 0.65
ExitMethod · 0.45

Tested by

no test coverage detected