-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
63 lines (46 loc) · 1.39 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
package main
import (
"fmt"
eq "github.com/wuriyanto48/go-ddd-grpc/server/query"
repo "github.com/wuriyanto48/go-ddd-grpc/server/repository"
serv "github.com/wuriyanto48/go-ddd-grpc/server/servers"
"google.golang.org/grpc"
"os"
)
const (
SERVER_CERT = "./cert/server.crt"
SERVER_KEY = "./cert/server.key"
CA = "./cert/server.crt"
)
func main() {
dbHost, ok := os.LookupEnv("DB_HOST")
if !ok {
fmt.Println("DB_HOST not set in environment variable or test script")
}
dbName, ok := os.LookupEnv("DB_NAME")
if !ok {
dbName = "gp"
}
dbUser, ok := os.LookupEnv("DB_USER")
if !ok {
fmt.Println("DB_USER not set in environmet variable or test script")
}
dbPassword, ok := os.LookupEnv("DB_PASSWORD")
if !ok {
fmt.Println("DB_USER not set in environmet variable or test script")
}
repoEmployee, err := repo.NewEmployeeRepoPostgres(dbHost, dbUser, dbPassword, dbName)
if err != nil {
fmt.Println("error during create repository employee")
}
queryEmployee, err := eq.NewQueryEmployeePostgres(dbHost, dbUser, dbPassword, dbName)
if err != nil {
fmt.Println("error during create query employee")
}
grpcServer := grpc.NewServer()
employeeServer := serv.NewEmployeeServer(grpcServer, repoEmployee, queryEmployee, SERVER_CERT, SERVER_KEY, CA)
err = employeeServer.ServeMutualTLS(8080)
if err != nil {
fmt.Sprintf("error create employee grpc server : %s", err)
}
}