-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (37 loc) · 1.03 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
package main
import (
"time"
"github.com/SonicRoshan/Velocity/global/config"
logger "github.com/SonicRoshan/Velocity/global/logs"
"github.com/SonicRoshan/Velocity/services/users-srv/handler"
proto "github.com/SonicRoshan/Velocity/services/users-srv/proto"
micro "github.com/micro/go-micro"
"go.uber.org/zap"
)
func main() {
//Loading logger
log := logger.GetLogger("users_service.log")
//Handling a panic
defer func() {
if r := recover(); r != nil {
log.Fatal("Service Paniced Due", zap.Any("Panic", r))
}
}()
service := micro.NewService(
micro.Name(config.UsersService),
micro.RegisterTTL(time.Second*30),
micro.RegisterInterval(time.Second*15),
)
service.Init()
usersService := handler.UsersService{}
err := usersService.Init()
if err != nil {
msg := "Not Able To Connect To MongoDB Server Due To Error " + err.Error()
log.Fatal(msg)
panic(msg)
}
proto.RegisterUsersHandler(service.Server(), usersService)
if err := service.Run(); err != nil {
log.Fatal("Service Failed With Error", zap.Error(err))
}
}