-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
37 lines (29 loc) · 921 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
37
package main
import (
"log"
"net"
"github.com/ClubWeGo/videomicro/dal"
videomicro "github.com/ClubWeGo/videomicro/kitex_gen/videomicro/videoservice"
"github.com/cloudwego/kitex/pkg/rpcinfo"
"github.com/cloudwego/kitex/server"
etcd "github.com/kitex-contrib/registry-etcd"
)
func main() {
// dsn := "tk:123456@tcp(127.0.0.1:3306)/simpletk?charset=utf8&parseTime=True&loc=Local"
dsn := "root:yutian@mysql+ssh(127.0.0.1:3306)/simpletk?charset=utf8&parseTime=True&loc=Local"
dal.InitDB(dsn)
r, err := etcd.NewEtcdRegistry([]string{"0.0.0.0:2379"})
if err != nil {
log.Fatal(err)
}
addr, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:10001")
svr := videomicro.NewServer(new(VideoServiceImpl),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "videoservice"}),
server.WithRegistry(r),
server.WithServiceAddr(addr),
)
err = svr.Run()
if err != nil {
log.Println(err.Error())
}
}