-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (61 loc) · 1.45 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
package main
import (
"log"
"net"
"sync"
"github.com/opentracing/opentracing-go"
zipkinot "github.com/openzipkin-contrib/zipkin-go-opentracing"
zipkin "github.com/openzipkin/zipkin-go"
httpReporter "github.com/openzipkin/zipkin-go/reporter/http"
"github.com/rosspatil/go-kit-example/endpoint"
"github.com/rosspatil/go-kit-example/pb"
"github.com/rosspatil/go-kit-example/service"
"github.com/rosspatil/go-kit-example/transport"
"google.golang.org/grpc"
)
var (
concurrency = 2
zipkinHTTPEndpoint = "http://localhost:9411/api/v2/spans"
)
func init() {
reporter := httpReporter.NewReporter(zipkinHTTPEndpoint)
ze, err := zipkin.NewEndpoint("go-kit-example", "localhost:8090")
if err != nil {
log.Fatalln(err)
}
nativeTracer, err := zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(ze))
if err != nil {
log.Fatalln(err)
}
tracer := zipkinot.Wrap(nativeTracer)
opentracing.InitGlobalTracer(tracer)
}
func main() {
wg := sync.WaitGroup{}
wg.Add(concurrency)
s := service.NewService()
e := endpoint.CreateEndPoint(*s)
go func() {
g := transport.NewHTTP(e)
err := g.Run(":8080")
if err != nil {
log.Fatal(err)
}
wg.Done()
}()
go func() {
g1 := transport.NewGRPC(e)
listener, err := net.Listen("tcp", "127.0.0.1:8091")
if err != nil {
log.Fatal(err)
}
server := grpc.NewServer()
pb.RegisterServiceServer(server, g1)
err = server.Serve(listener)
if err != nil {
log.Fatal(err)
}
wg.Done()
}()
wg.Wait()
}