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

Function Run

IceFireDB-SQLProxy/internal/mysql/server.go:17–54  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

15)
16
17func Run(ctx context.Context) (err error) {
18 ms := newMysqlProxy()
19 ms.ctx = ctx
20 ms.closed.Store(true)
21
22 if err = ms.initClientPool(); err != nil {
23 return fmt.Errorf("initClientPool error: %v", err)
24 }
25 ln, err := net.Listen("tcp4", config.Get().Server.Addr)
26 if err != nil {
27 logrus.Errorf("mysql%v", err)
28 return
29 }
30 utils.GoWithRecover(func() {
31 if <-ctx.Done(); true {
32 _ = ln.Close()
33 ms.closed.Store(true)
34 }
35 }, nil)
36
37 ms.closed.Store(false)
38 logrus.Infof("%s\n", config.Get().Server.Addr)
39 // p2p
40 if config.Get().P2P.Enable {
41 initP2P(ms)
42 }
43 for {
44 conn, err := ln.Accept()
45 if err != nil {
46 if errors.Is(err, io.EOF) || errors.Is(err, net.ErrClosed) {
47 continue
48 }
49 panic(err)
50 }
51 go ms.onConn(conn)
52 }
53 return
54}
55
56func newMysqlProxy() *mysqlProxy {
57 p := &mysqlProxy{}

Callers 1

mainFunction · 0.92

Calls 8

GetFunction · 0.92
GoWithRecoverFunction · 0.92
initP2PFunction · 0.85
initClientPoolMethod · 0.80
DoneMethod · 0.80
newMysqlProxyFunction · 0.70
CloseMethod · 0.65
onConnMethod · 0.45

Tested by

no test coverage detected