-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (40 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
48
49
50
51
52
53
54
package main
import (
"context"
"flag"
"fmt"
"log"
"time"
"github.com/mahendrarathore1742/priceFetcher/client"
"github.com/mahendrarathore1742/priceFetcher/proto"
)
func main() {
// client := client.New("http://localhost:3000")
// price, err := client.FetcherPrice(context.Background(), "ET")
// if err != nil {
// log.Fatal(err)
// }
// fmt.Printf("%+v\n", price)
var (
jsonAddr = flag.String("json", ":3000", "listen address of the json transport")
grpcAddr = flag.String("grpc", ":4000", "listen address of the grpc transport")
svc = loggingService{&priceService{}}
ctx = context.Background()
)
flag.Parse()
grpcClient, err := client.NewGRPCClinet(":4000")
if err != nil {
log.Fatal(err)
}
go func() {
time.Sleep(3 * time.Second)
resp, err := grpcClient.FetchPrice(ctx, &proto.PriceRequest{Ticker: "BTC"})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}()
go makeGRPCServerAndRun(*grpcAddr, svc)
jsonServer := NewJsonAPiServer(*jsonAddr, svc)
jsonServer.Run()
}