-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (41 loc) · 1.38 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
package main
import (
zipkin "github.com/openzipkin/zipkin-go-opentracing"
"github.com/opentracing/opentracing-go"
"net/http"
"log"
"github.com/luismoramedina/gomezh/egress"
"github.com/luismoramedina/gomezh/sidecar"
"github.com/luismoramedina/gomezh/ingress"
"time"
)
func main() {
var tracer opentracing.Tracer
authMap := sidecar.NewAuthsMap()
timeMap := sidecar.NewTimeMap()
// 1) Create a opentracing.Tracer that does nothing, use a
collector := new(zipkin.NopCollector)
tracer, _ = zipkin.NewTracer(
zipkin.NewRecorder(collector, false, "127.0.0.1:0", "mesh"))
egressController := egress.EgressController{
Sidecar: sidecar.Sidecar{
Tracer: tracer, Auths: authMap, Times: timeMap}}
ingressController := ingress.IngressController{
Sidecar: sidecar.Sidecar{
Tracer: tracer, Auths: authMap, Times: timeMap}}
ingressHandler := http.HandlerFunc(ingressController.Handler)
egressHandler := http.HandlerFunc(egressController.Handler)
log.Printf("Listening ingress %s, egress %s", ":8080" ,":8082")
ingressServer := &http.Server{
Addr: ":8080",
Handler: ingress.SecurityMiddleware(ingressHandler),
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second}
egressServer := &http.Server{
Addr: ":8082",
Handler: egressHandler,
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second}
go egressServer.ListenAndServe()
ingressServer.ListenAndServe()
}