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

Method Run

IceFireDB-SQLite/internal/mysql/server.go:20–52  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

18}
19
20func (m *mysqlProxy) Run(ctx context.Context) {
21 m.ctx = ctx
22 m.closed.Store(true)
23 ln, err := net.Listen("tcp4", config.Get().Server.Addr)
24 if err != nil {
25 logrus.Errorf("IceFireDB-SQLite listen fail:%v", err)
26 return
27 }
28 utils.GoWithRecover(func() {
29 if <-ctx.Done(); true {
30 _ = ln.Close()
31 m.closed.Store(true)
32 }
33 }, nil)
34
35 m.closed.Store(false)
36
37 logrus.Infof("IceFireDB-SQLite listening:%s\n", config.Get().Server.Addr)
38
39 // init sqlitedb
40 db := sqlite.InitSQLite(ctx, config.Get().SQLite.Filename)
41 m.db = db
42 for {
43 conn, err := ln.Accept()
44 if err != nil {
45 if errors.Is(err, io.EOF) || errors.Is(err, net.ErrClosed) {
46 return
47 }
48 panic(err)
49 }
50 go m.onConn(conn)
51 }
52}
53
54func newMysqlProxy() *mysqlProxy {
55 p := &mysqlProxy{}

Callers 2

mainFunction · 0.45
mainFunction · 0.45

Calls 6

onConnMethod · 0.95
GetFunction · 0.92
GoWithRecoverFunction · 0.92
InitSQLiteFunction · 0.92
DoneMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected