-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 820 Bytes
/
main.go
File metadata and controls
35 lines (27 loc) · 820 Bytes
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
package main
import (
"github.com/ClubWeGo/usermicro/dal"
usermicro "github.com/ClubWeGo/usermicro/kitex_gen/usermicro/userservice"
"log"
"net"
"github.com/cloudwego/kitex/pkg/rpcinfo"
"github.com/cloudwego/kitex/server"
etcd "github.com/kitex-contrib/registry-etcd"
)
func main() {
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:10000")
svr := usermicro.NewServer(new(UserServiceImpl),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "userservice"}),
server.WithRegistry(r),
server.WithServiceAddr(addr))
err = svr.Run()
if err != nil {
log.Println(err.Error())
}
}