Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Propagate context to gocql backend
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Jun 4, 2020
1 parent 60ec0b6 commit 25511c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gocql_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func (cb goCQLBackend) QueryWithOptions(opts Options, stmt Statement, scanner Sc
if opts.Consistency != nil {
qu = qu.Consistency(*opts.Consistency)
}
if opts.Context != nil {
qu.WithContext(opts.Context)
}

iter := qu.Iter()
if _, err := scanner.ScanIter(iter.Scanner()); err != nil {
Expand All @@ -35,6 +38,9 @@ func (cb goCQLBackend) ExecuteWithOptions(opts Options, stmt Statement) error {
if opts.Consistency != nil {
qu = qu.Consistency(*opts.Consistency)
}
if opts.Context != nil {
qu.WithContext(opts.Context)
}
return qu.Exec()
}

Expand All @@ -55,6 +61,9 @@ func (cb goCQLBackend) ExecuteAtomicallyWithOptions(opts Options, stmts []Statem
if opts.Consistency != nil {
batch.Cons = *opts.Consistency
}
if opts.Context != nil {
batch.WithContext(opts.Context)
}

return cb.session.ExecuteBatch(batch)
}
Expand Down

0 comments on commit 25511c9

Please sign in to comment.