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

Function NewMySQLProxy

IceFireDB-SQLProxy/internal/mysql/proxy.go:33–73  ·  view source on GitHub ↗
(ctx context.Context, server *server.Server, credential server.CredentialProvider)

Source from the content-addressed store, hash-verified

31}
32
33func NewMySQLProxy(ctx context.Context, server *server.Server, credential server.CredentialProvider) *mysqlProxy {
34 proxy := &mysqlProxy{
35 ctx: ctx,
36 server: server,
37 credential: credential,
38 }
39
40 // Initialize admin connection pool
41 adminPool, err := client.NewPool(
42 logrus.Infof,
43 config.Get().Mysql.Admin.MinAlive,
44 config.Get().Mysql.Admin.MaxAlive,
45 config.Get().Mysql.Admin.MaxIdle,
46 config.Get().Mysql.Admin.Addr,
47 config.Get().Mysql.Admin.User,
48 config.Get().Mysql.Admin.Password,
49 config.Get().Mysql.Admin.DBName,
50 )
51 if err != nil {
52 logrus.Fatalf("Failed to create admin pool: %v", err)
53 }
54 proxy.adminPool = adminPool
55
56 // Initialize readonly connection pool
57 readonlyPool, err := client.NewPool(
58 logrus.Infof,
59 config.Get().Mysql.Readonly.MinAlive,
60 config.Get().Mysql.Readonly.MaxAlive,
61 config.Get().Mysql.Readonly.MaxIdle,
62 config.Get().Mysql.Readonly.Addr,
63 config.Get().Mysql.Readonly.User,
64 config.Get().Mysql.Readonly.Password,
65 config.Get().Mysql.Readonly.DBName,
66 )
67 if err != nil {
68 logrus.Fatalf("Failed to create readonly pool: %v", err)
69 }
70 proxy.readonlyPool = readonlyPool
71
72 return proxy
73}
74
75func (m *mysqlProxy) onConn(c net.Conn) {
76 // Default to admin connection for direct connections

Callers

nothing calls this directly

Calls 2

NewPoolFunction · 0.92
GetFunction · 0.92

Tested by

no test coverage detected