Skip to content

Commit

Permalink
GOCBC-1400: Add missing connection string timeout parsing
Browse files Browse the repository at this point in the history
Motivation
----------
We allow users to specify timeouts in the connection string, however
we are missing some fields - most noticeably kv timeouts.

Changes
--------
Update connection string parsing to parse kv_timeout,
kv_durable_timeout, kv_scan_timeout, and management_timeout.

Change-Id: Iace865110e891fbb75c233f4cb6648d35610ed14
Reviewed-on: https://review.couchbase.org/c/gocb/+/189016
Reviewed-by: Dimitris Christodoulou <[email protected]>
Tested-by: Charles Dixon <[email protected]>
  • Loading branch information
chvck committed Apr 13, 2023
1 parent 0719217 commit 4bcd966
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,31 @@ func (c *Cluster) parseExtraConnStrOptions(spec gocbconnstr.ConnSpec) error {
return optValue[len(optValue)-1], true
}

if valStr, ok := fetchOption("kv_timeout"); ok {
val, err := strconv.ParseInt(valStr, 10, 64)
if err != nil {
return fmt.Errorf("query_timeout option must be a number")
}
c.timeoutsConfig.KVTimeout = time.Duration(val) * time.Millisecond
}

if valStr, ok := fetchOption("kv_durable_timeout"); ok {
val, err := strconv.ParseInt(valStr, 10, 64)
if err != nil {
return fmt.Errorf("query_timeout option must be a number")
}
c.timeoutsConfig.KVDurableTimeout = time.Duration(val) * time.Millisecond
}

// Volatile: This option is subject to change at any time.
if valStr, ok := fetchOption("kv_scan_timeout"); ok {
val, err := strconv.ParseInt(valStr, 10, 64)
if err != nil {
return fmt.Errorf("query_timeout option must be a number")
}
c.timeoutsConfig.KVScanTimeout = time.Duration(val) * time.Millisecond
}

if valStr, ok := fetchOption("query_timeout"); ok {
val, err := strconv.ParseInt(valStr, 10, 64)
if err != nil {
Expand Down Expand Up @@ -341,6 +366,14 @@ func (c *Cluster) parseExtraConnStrOptions(spec gocbconnstr.ConnSpec) error {
c.timeoutsConfig.ViewTimeout = time.Duration(val) * time.Millisecond
}

if valStr, ok := fetchOption("management_timeout"); ok {
val, err := strconv.ParseInt(valStr, 10, 64)
if err != nil {
return fmt.Errorf("view_timeout option must be a number")
}
c.timeoutsConfig.ManagementTimeout = time.Duration(val) * time.Millisecond
}

return nil
}

Expand Down

0 comments on commit 4bcd966

Please sign in to comment.