-
Notifications
You must be signed in to change notification settings - Fork 3
/
lssd_clients.go
52 lines (47 loc) · 1.8 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
50
51
52
package main
import (
"fmt"
"github.com/cwntr/go-dex-client/lssdrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
"log"
"time"
)
// 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 Currency 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
params := keepalive.ClientParameters{}
params.Timeout = time.Duration(time.Second * 350)
conn, err := grpc.Dial(fmt.Sprintf("%s:%d", "", cfg.LSSDConfig.Port), grpc.WithInsecure(), grpc.WithBlock(), grpc.WithKeepaliveParams(params))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
return lssdrpc.NewOrdersClient(conn), conn
}