Skip to content

Commit

Permalink
Improve reconnection policy and context handling in Queryx
Browse files Browse the repository at this point in the history
  • Loading branch information
itsfuad committed Jan 29, 2025
1 parent 2f79f86 commit b1bf7e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gocqlxtest/gocqlxtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func CreateCluster() *gocql.ClusterConfig {
cluster.Timeout = *flagTimeout
cluster.Consistency = gocql.Quorum
cluster.MaxWaitSchemaAgreement = 2 * time.Minute // travis might be slow
cluster.ReconnectionPolicy = &gocql.ConstantReconnectionPolicy{
MaxRetries: 10,
Interval: 3 * time.Second,
}
if *flagRetry > 0 {
cluster.RetryPolicy = &gocql.SimpleRetryPolicy{NumRetries: *flagRetry}
}
Expand Down
3 changes: 3 additions & 0 deletions queryx_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func (q *Queryx) RoutingKey(routingKey []byte) *Queryx {
// query, queries will be canceled and return once the context is
// canceled.
func (q *Queryx) WithContext(ctx context.Context) *Queryx {
if ctx == nil {
ctx = context.Background()
}
q.Query = q.Query.WithContext(ctx)
return q
}
Expand Down

0 comments on commit b1bf7e7

Please sign in to comment.