-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
74 lines (62 loc) · 1.8 KB
/
options.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package astra
import (
"crypto/tls"
"time"
"google.golang.org/grpc"
)
// ClientOption is an option for a Client.
type ClientOption func(*Client)
// WithDeadline sets the deadline for the initial connection.
func WithDeadline(deadline time.Duration) ClientOption {
return func(c *Client) {
c.deadline = deadline
}
}
// WithTimeout sets the timeout for queries.
func WithTimeout(timeout time.Duration) ClientOption {
return func(c *Client) {
c.timeout = timeout
}
}
// WithDefaultKeyspace specifies the default keyspace for client queries.
func WithDefaultKeyspace(keyspace string) ClientOption {
return func(c *Client) {
c.defaultQueryParams.keyspace(keyspace)
}
}
// WithGRPCConnParams specifies other connection parameters to use for the gRPC
// connection.
func WithGRPCConnParams(params *grpc.ConnectParams) ClientOption {
return func(c *Client) {
c.grpcConnParams = params
}
}
// WithTLSConfig specifies the TLS configuration to use for the gRPC connection.
func WithTLSConfig(config *tls.Config) ClientOption {
return func(c *Client) {
c.tlsConfig = config
}
}
// WithInsecure specifies whether to use an insecure connection. Intended
// localhost testing only.
func WithInsecure(insecure bool) ClientOption {
return func(c *Client) {
c.insecure = insecure
}
}
// StaticTokenConnectConfig describes a connection method to use in a call to
// NewStaticTokenClient.
type StaticTokenConnectConfig func(*Client)
// WithAstraURI specifies the Astra URI to use for the gRPC connection.
func WithAstraURI(uri string) StaticTokenConnectConfig {
return func(c *Client) {
c.astraURI = uri
}
}
// WithSecureConnectBundle specifies the secure connect bundle to use for the
// gRPC connection.
func WithSecureConnectBundle(path string) StaticTokenConnectConfig {
return func(c *Client) {
c.scbPath = path
}
}