-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmain.go
48 lines (40 loc) · 1.07 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"log"
"net"
"toktik/constant/config"
publish "toktik/kitex_gen/douyin/publish/publishservice"
"github.com/kitex-contrib/obs-opentelemetry/provider"
"github.com/kitex-contrib/obs-opentelemetry/tracing"
"github.com/cloudwego/kitex/server"
"github.com/cloudwego/kitex/pkg/rpcinfo"
consul "github.com/kitex-contrib/registry-consul"
)
func main() {
r, err := consul.NewConsulRegister(config.EnvConfig.CONSUL_ADDR)
if err != nil {
log.Fatal(err)
}
addr, err := net.ResolveTCPAddr("tcp", config.PublishServiceAddr)
if err != nil {
panic(err)
}
provider.NewOpenTelemetryProvider(
provider.WithServiceName(config.PublishServiceName),
provider.WithExportEndpoint(config.EnvConfig.EXPORT_ENDPOINT),
provider.WithInsecure(),
)
srv := publish.NewServer(
new(PublishServiceImpl),
server.WithServiceAddr(addr),
server.WithRegistry(r),
server.WithSuite(tracing.NewServerSuite()),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{
ServiceName: config.PublishServiceName,
}),
)
err = srv.Run()
if err != nil {
log.Fatal(err)
}
}