/
main.go
32 lines (29 loc) · 1.02 KB
/
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
package main
import (
"log"
"net"
db "github.com/808-not-found/tik_duck/cmd/userplat/dal/db"
userplat "github.com/808-not-found/tik_duck/kitex_gen/userplat/userplatservice"
"github.com/808-not-found/tik_duck/pkg/consts"
"github.com/808-not-found/tik_duck/pkg/middleware"
"github.com/cloudwego/kitex/pkg/rpcinfo"
server "github.com/cloudwego/kitex/server"
etcd "github.com/kitex-contrib/registry-etcd"
)
func main() {
r, err := etcd.NewEtcdRegistry([]string{consts.EtcdAddress})
if err != nil {
panic(err)
}
addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:10002")
svr := userplat.NewServer(new(UserPlatServiceImpl),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.UserPlatServiceName}), // server name
server.WithMiddleware(middleware.CommonMiddleware), // middleWare
server.WithMiddleware(middleware.ServerMiddleware),
server.WithServiceAddr(addr), server.WithRegistry(r))
db.Init()
err = svr.Run()
if err != nil {
log.Println(err.Error())
}
}