-
Notifications
You must be signed in to change notification settings - Fork 0
/
livemap.pb.tester.go
49 lines (40 loc) · 1.19 KB
/
livemap.pb.tester.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
// Code generated by protoc-gen-customizer. DO NOT EDIT.
// source: services/livemapper/livemap.proto
package livemapper
import (
"context"
"log"
"net"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
)
func NewTestLivemapperServiceClient(srv LivemapperServiceServer) (LivemapperServiceClient, context.Context, context.CancelFunc) {
ctx, cancel := context.WithCancel(context.Background())
buffer := 101024 * 1024
lis := bufconn.Listen(buffer)
server := grpc.NewServer()
RegisterLivemapperServiceServer(server, srv)
go func() {
if err := server.Serve(lis); err != nil {
log.Printf("error serving test grpc server: %v", err)
}
}()
conn, err := grpc.DialContext(ctx, "",
grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
return lis.Dial()
}), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Printf("error connecting to test grpc server: %v", err)
}
go func() {
<-ctx.Done()
err := lis.Close()
if err != nil {
log.Printf("error closing listener: %v", err)
}
server.Stop()
}()
client := NewLivemapperServiceClient(conn)
return client, ctx, cancel
}