-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
57 lines (49 loc) · 1.29 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
package main
import (
"fmt"
"os"
"time"
"github.com/kumarabd/gokit/logger"
"github.com/layer5io/meshery-adapter-template/adaptor"
"github.com/layer5io/meshery-adapter-template/api/grpc"
"github.com/layer5io/meshery-adapter-template/internal/config"
"github.com/layer5io/meshery-adapter-template/internal/tracing"
)
var (
configProvider = "local"
)
// main is the entrypoint of the adaptor
func main() {
// Initialize application specific configs and dependencies
// App and request config
cfg, err := config.New(configProvider)
if err != nil {
fmt.Println("Config Init Failed", err.Error())
os.Exit(1)
}
service := &grpc.Service{}
_ = cfg.Server(&service)
// Initialize Logger instance
log, err := logger.New(service.Name)
if err != nil {
fmt.Println("Logger Init Failed", err.Error())
os.Exit(1)
}
// Initialize Tracing instance
traceProvider, err := tracing.New(service.Name, service.TraceURL)
if err != nil {
fmt.Println("Tracing Init Failed", err.Error())
os.Exit(1)
}
// Initialize Handler intance
handler := adaptor.New(cfg, log)
service.Handler = handler
service.StartedAt = time.Now()
// Server Initialization
log.Info("Adaptor Started")
err = grpc.Start(service, traceProvider)
if err != nil {
log.Err("Adaptor crashed!!", err.Error())
os.Exit(1)
}
}