@@ -21,16 +21,25 @@ import (
21
21
_ "github.com/scylladb/gocqlx/v3/table"
22
22
)
23
23
24
+ var defaultClusterConfig = gocql .NewCluster ()
25
+
26
+ var (
27
+ defaultQueryTimeout = defaultClusterConfig .Timeout
28
+ defaultConnectionTimeout = defaultClusterConfig .ConnectTimeout
29
+ )
30
+
24
31
var (
25
- cmd = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
26
- flagCluster = cmd .String ("cluster" , "127.0.0.1" , "a comma-separated list of host:port tuples" )
27
- flagKeyspace = cmd .String ("keyspace" , "" , "keyspace to inspect" )
28
- flagPkgname = cmd .String ("pkgname" , "models" , "the name you wish to assign to your generated package" )
29
- flagOutput = cmd .String ("output" , "models" , "the name of the folder to output to" )
30
- flagUser = cmd .String ("user" , "" , "user for password authentication" )
31
- flagPassword = cmd .String ("password" , "" , "password for password authentication" )
32
- flagIgnoreNames = cmd .String ("ignore-names" , "" , "a comma-separated list of table, view or index names to ignore" )
33
- flagIgnoreIndexes = cmd .Bool ("ignore-indexes" , false , "don't generate types for indexes" )
32
+ cmd = flag .NewFlagSet (os .Args [0 ], flag .ExitOnError )
33
+ flagCluster = cmd .String ("cluster" , "127.0.0.1" , "a comma-separated list of host:port tuples" )
34
+ flagKeyspace = cmd .String ("keyspace" , "" , "keyspace to inspect" )
35
+ flagPkgname = cmd .String ("pkgname" , "models" , "the name you wish to assign to your generated package" )
36
+ flagOutput = cmd .String ("output" , "models" , "the name of the folder to output to" )
37
+ flagUser = cmd .String ("user" , "" , "user for password authentication" )
38
+ flagPassword = cmd .String ("password" , "" , "password for password authentication" )
39
+ flagIgnoreNames = cmd .String ("ignore-names" , "" , "a comma-separated list of table, view or index names to ignore" )
40
+ flagIgnoreIndexes = cmd .Bool ("ignore-indexes" , false , "don't generate types for indexes" )
41
+ flagQueryTimeout = cmd .Duration ("query-timeout" , defaultQueryTimeout , "query timeout ( in seconds )" )
42
+ flagConnectionTimeout = cmd .Duration ("connection-timeout" , defaultConnectionTimeout , "connection timeout ( in seconds )" )
34
43
)
35
44
36
45
//go:embed keyspace.tmpl
@@ -152,6 +161,12 @@ func createSession() (gocqlx.Session, error) {
152
161
Password : * flagPassword ,
153
162
}
154
163
}
164
+ if * flagQueryTimeout >= 0 {
165
+ cluster .Timeout = * flagQueryTimeout
166
+ }
167
+ if * flagConnectionTimeout >= 0 {
168
+ cluster .ConnectTimeout = * flagConnectionTimeout
169
+ }
155
170
return gocqlx .WrapSession (cluster .CreateSession ())
156
171
}
157
172
0 commit comments