-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (33 loc) · 785 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"context"
"gorm-test/server"
"gorm-test/syncx"
"log"
)
// can't use one SingleFlight per conn, because multiple conns may share the same cache key.
var singleFlights = syncx.NewSingleFlight()
func main() {
client := server.GormMysql(&server.MysqlConfig{
Path: "localhost",
Password: "yourpassword",
Dbname: "gorm",
Username: "root",
Port: "3306",
MaxIdleConns: 8,
MaxOpenConns: 8,
})
log.Println(client)
ctx := context.Background()
r := server.Redis(&server.RedisConfig{
Addr: "127.0.0.1:6379",
Password: "",
DB: 0,
})
srv := server.NewGetService(client, r, singleFlights)
info, err := srv.FindOne(ctx, 1)
if err != nil {
log.Fatalf(err.Error())
}
log.Println(info.TradeStateDesc)
}