forked from matthewmcneely/modusGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdial_options_example_test.go
More file actions
35 lines (31 loc) · 1.01 KB
/
Copy pathdial_options_example_test.go
File metadata and controls
35 lines (31 loc) · 1.01 KB
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
/*
* SPDX-FileCopyrightText: © 2017-2026 Istari Digital, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
package modusgraph_test
import (
"time"
mg "github.com/matthewmcneely/modusgraph"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
)
// ExampleWithGRPCDialOption configures gRPC dial settings the dedicated options
// do not cover — here, transport credentials and keepalive parameters — when
// opening a remote dgraph:// connection. Each WithGRPCDialOption adds one
// grpc.DialOption; they compose with WithMaxRecvMsgSize. The options are ignored
// for embedded (file://) URIs.
func ExampleWithGRPCDialOption() {
client, err := mg.NewClient(
"dgraph://localhost:9080",
mg.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())),
mg.WithGRPCDialOption(grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 30 * time.Second,
Timeout: 10 * time.Second,
})),
)
if err != nil {
panic(err)
}
defer client.Close()
}