-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (55 loc) · 1.36 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"log"
"net"
"time"
"github.com/amdf/conv-get-img/internal/config"
"github.com/amdf/conv-get-img/internal/server"
pb "github.com/amdf/conv-get-img/svc"
"google.golang.org/grpc"
opentracing "github.com/opentracing/opentracing-go"
jaeger "github.com/uber/jaeger-client-go"
jcfg "github.com/uber/jaeger-client-go/config"
)
func main() {
if errload := config.Load(); errload != nil {
log.Fatal("unable to load configs/config.toml: ", errload.Error())
}
newjcfg := jcfg.Configuration{
Sampler: &jcfg.SamplerConfig{
Type: "const",
Param: 1,
},
Reporter: &jcfg.ReporterConfig{
LogSpans: true,
BufferFlushInterval: 1 * time.Second,
},
}
tracer, closer, jerr := newjcfg.New(
"conv-get-img",
jcfg.Logger(jaeger.StdLogger),
)
if jerr != nil {
log.Fatalln("fail to create tracing", jerr)
}
opentracing.SetGlobalTracer(tracer)
defer closer.Close()
srv, err := server.NewServer()
if err != nil {
log.Fatalln("fail to create server", err)
}
lis, err := net.Listen("tcp", config.GetServerAddress())
if err != nil {
log.Fatalln("fail to listen", err)
}
s := grpc.NewServer(
//grpc.InTapHandle(server.RateLimiter),
)
pb.RegisterConvGetImageServer(s, srv)
log.Println("starting server at ", lis.Addr())
go srv.RunGateway()
err = s.Serve(lis)
if err != nil {
log.Fatalln("server failed", err)
}
}