Skip to content

Commit

Permalink
Add Query.RetryPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
dipeshhkc authored and willfaught committed Nov 30, 2024
1 parent d8afaf9 commit c3cf2d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ type Query interface {
// SERIAL. This option will be ignored for anything else that a
// conditional update/insert.
SerialConsistency(cons gocql.SerialConsistency) Query

// RetryPolicy sets the policy to use when retrying the query.
RetryPolicy(r gocql.RetryPolicy) Query
}

var (
Expand Down Expand Up @@ -140,6 +143,10 @@ func (m QueryMock) Consistency(c gocql.Consistency) Query {
return m.Called(c).Get(0).(Query)
}

func (m QueryMock) RetryPolicy(r gocql.RetryPolicy) Query {
return m.Called(r).Get(0).(Query)
}

func (m QueryMock) SerialConsistency(c gocql.SerialConsistency) Query {
return m.Called(c).Get(0).(Query)
}
Expand Down Expand Up @@ -199,3 +206,7 @@ func (q query) SerialConsistency(cons gocql.SerialConsistency) Query {
func (q query) MapScanCAS(dest map[string]interface{}) (applied bool, err error) {
return q.q.MapScanCAS(dest)
}

func (q query) RetryPolicy(r gocql.RetryPolicy) Query {
return &query{q: q.q.RetryPolicy(r)}
}
2 changes: 2 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func TestQueryMock(t *testing.T) {
var m, e = &QueryMock{}, fmt.Errorf("e")
ctx := context.Background()
it := &IteratorMock{}
rt := &gocql.SimpleRetryPolicy{NumRetries: 3}
testMock(t, m, &m.Mock, []struct {
method string
arguments []interface{}
Expand All @@ -80,6 +81,7 @@ func TestQueryMock(t *testing.T) {
{"SetConsistency", []interface{}{gocql.One}, nil},
{"Consistency", []interface{}{gocql.One}, []interface{}{m}},
{"SerialConsistency", []interface{}{gocql.LocalSerial}, []interface{}{m}},
{"RetryPolicy", []interface{}{rt}, []interface{}{m}},
})
}

Expand Down

0 comments on commit c3cf2d3

Please sign in to comment.