-
Notifications
You must be signed in to change notification settings - Fork 1
/
lssd_clients.go
49 lines (43 loc) · 1.64 KB
/
lssd_clients.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
package main
import (
"fmt"
"log"
"github.com/cwntr/go-dex-trading-bot/lssdrpc"
"google.golang.org/grpc"
)
// createSwapClient creates a gRPC connection for the Swaps service
func createSwapClient() (lssdrpc.SwapsClient, *grpc.ClientConn) {
var conn *grpc.ClientConn
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", "", cfg.LSSDConfig.Port), grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return lssdrpc.NewSwapsClient(conn), conn
}
// createSwapClient creates a gRPC connection for the Currency service
func createCurrencyClient() (lssdrpc.CurrenciesClient, *grpc.ClientConn) {
var conn *grpc.ClientConn
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", "", cfg.LSSDConfig.Port), grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return lssdrpc.NewCurrenciesClient(conn), conn
}
// createTradingPairClient creates a gRPC connection for the TradingPair service
func createTradingPairClient() (lssdrpc.TradingPairsClient, *grpc.ClientConn) {
var conn *grpc.ClientConn
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", "", cfg.LSSDConfig.Port), grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return lssdrpc.NewTradingPairsClient(conn), conn
}
// createOrdersClient creates a gRPC connection for the Order service
func createOrdersClient() (lssdrpc.OrdersClient, *grpc.ClientConn) {
var conn *grpc.ClientConn
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", "", cfg.LSSDConfig.Port), grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return lssdrpc.NewOrdersClient(conn), conn
}