Skip to content

Commit

Permalink
Add Query.SerialConsistency()
Browse files Browse the repository at this point in the history
  • Loading branch information
max-melentyev authored and willfaught committed Feb 8, 2024
1 parent d04cbbc commit d8afaf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ type Query interface {
// level has been set, the default consistency level of the cluster
// is used.
Consistency(c gocql.Consistency) Query

// SerialConsistency sets the consistency level for the
// serial phase of conditional updates. That consistency can only be
// either SERIAL or LOCAL_SERIAL and if not present, it defaults to
// SERIAL. This option will be ignored for anything else that a
// conditional update/insert.
SerialConsistency(cons gocql.SerialConsistency) Query
}

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

func (m QueryMock) SerialConsistency(c gocql.SerialConsistency) Query {
return m.Called(c).Get(0).(Query)
}

type query struct {
q *gocql.Query
}
Expand Down Expand Up @@ -181,6 +192,10 @@ func (q query) Consistency(c gocql.Consistency) Query {
return &query{q: q.q.Consistency(c)}
}

func (q query) SerialConsistency(cons gocql.SerialConsistency) Query {
return &query{q: q.q.SerialConsistency(cons)}
}

func (q query) MapScanCAS(dest map[string]interface{}) (applied bool, err error) {
return q.q.MapScanCAS(dest)
}
1 change: 1 addition & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestQueryMock(t *testing.T) {
{"GetConsistency", nil, []interface{}{gocql.Quorum}},
{"SetConsistency", []interface{}{gocql.One}, nil},
{"Consistency", []interface{}{gocql.One}, []interface{}{m}},
{"SerialConsistency", []interface{}{gocql.LocalSerial}, []interface{}{m}},
})
}

Expand Down

0 comments on commit d8afaf9

Please sign in to comment.