Skip to content

Commit bfa15ce

Browse files
authored
Merge pull request #131 from ConnorJC3/master
Add timeout to connection.Connect()
2 parents 1b2426d + bbcd132 commit bfa15ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

connection/connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func SetMaxGRPCLogLength(characterCount int) {
5454
// file or have format '<protocol>://', following gRPC name resolution mechanism at
5555
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
5656
//
57-
// The function tries to connect indefinitely every second until it connects. The function automatically disables TLS
58-
// and adds interceptor for logging of all gRPC messages at level 5.
57+
// The function tries to connect for 30 seconds, and returns an error if no connection has been established at that point.
58+
// The function automatically disables TLS and adds interceptor for logging of all gRPC messages at level 5.
5959
//
6060
// For a connection to a Unix Domain socket, the behavior after
6161
// loosing the connection is configurable. The default is to
@@ -70,7 +70,7 @@ func SetMaxGRPCLogLength(characterCount int) {
7070
// For other connections, the default behavior from gRPC is used and
7171
// loss of connection is not detected reliably.
7272
func Connect(address string, metricsManager metrics.CSIMetricsManager, options ...Option) (*grpc.ClientConn, error) {
73-
return connect(address, metricsManager, []grpc.DialOption{}, options)
73+
return connect(address, metricsManager, []grpc.DialOption{grpc.WithTimeout(time.Second * 30)}, options)
7474
}
7575

7676
// Option is the type of all optional parameters for Connect.

0 commit comments

Comments
 (0)