@@ -192,6 +192,9 @@ const (
192192
193193type Consistency uint16
194194
195+ // SerialConsistency is deprecated. Use Consistency instead.
196+ type SerialConsistency = Consistency
197+
195198const (
196199 Any Consistency = 0x00
197200 One Consistency = 0x01
@@ -202,6 +205,8 @@ const (
202205 LocalQuorum Consistency = 0x06
203206 EachQuorum Consistency = 0x07
204207 LocalOne Consistency = 0x0A
208+ Serial Consistency = 0x08
209+ LocalSerial Consistency = 0x09
205210)
206211
207212func (c Consistency ) String () string {
@@ -224,6 +229,10 @@ func (c Consistency) String() string {
224229 return "EACH_QUORUM"
225230 case LocalOne :
226231 return "LOCAL_ONE"
232+ case Serial :
233+ return "SERIAL"
234+ case LocalSerial :
235+ return "LOCAL_SERIAL"
227236 default :
228237 return fmt .Sprintf ("UNKNOWN_CONS_0x%x" , uint16 (c ))
229238 }
@@ -253,13 +262,21 @@ func (c *Consistency) UnmarshalText(text []byte) error {
253262 * c = EachQuorum
254263 case "LOCAL_ONE" :
255264 * c = LocalOne
265+ case "SERIAL" :
266+ * c = Serial
267+ case "LOCAL_SERIAL" :
268+ * c = LocalSerial
256269 default :
257270 return fmt .Errorf ("invalid consistency %q" , string (text ))
258271 }
259272
260273 return nil
261274}
262275
276+ func (c Consistency ) IsSerial () bool {
277+ return c == Serial || c == LocalSerial
278+
279+ }
263280func ParseConsistency (s string ) Consistency {
264281 var c Consistency
265282 if err := c .UnmarshalText ([]byte (strings .ToUpper (s ))); err != nil {
@@ -286,41 +303,6 @@ func MustParseConsistency(s string) (Consistency, error) {
286303 return c , nil
287304}
288305
289- type SerialConsistency uint16
290-
291- const (
292- Serial SerialConsistency = 0x08
293- LocalSerial SerialConsistency = 0x09
294- )
295-
296- func (s SerialConsistency ) String () string {
297- switch s {
298- case Serial :
299- return "SERIAL"
300- case LocalSerial :
301- return "LOCAL_SERIAL"
302- default :
303- return fmt .Sprintf ("UNKNOWN_SERIAL_CONS_0x%x" , uint16 (s ))
304- }
305- }
306-
307- func (s SerialConsistency ) MarshalText () (text []byte , err error ) {
308- return []byte (s .String ()), nil
309- }
310-
311- func (s * SerialConsistency ) UnmarshalText (text []byte ) error {
312- switch string (text ) {
313- case "SERIAL" :
314- * s = Serial
315- case "LOCAL_SERIAL" :
316- * s = LocalSerial
317- default :
318- return fmt .Errorf ("invalid consistency %q" , string (text ))
319- }
320-
321- return nil
322- }
323-
324306const (
325307 apacheCassandraTypePrefix = "org.apache.cassandra.db.marshal."
326308)
@@ -1452,7 +1434,7 @@ type queryParams struct {
14521434 values []queryValues
14531435 pageSize int
14541436 pagingState []byte
1455- serialConsistency SerialConsistency
1437+ serialConsistency Consistency
14561438 // v3+
14571439 defaultTimestamp bool
14581440 defaultTimestampValue int64
@@ -1541,7 +1523,7 @@ func (f *framer) writeQueryParams(opts *queryParams) {
15411523 }
15421524
15431525 if opts .serialConsistency > 0 {
1544- f .writeConsistency (Consistency ( opts .serialConsistency ) )
1526+ f .writeConsistency (opts .serialConsistency )
15451527 }
15461528
15471529 if f .proto > protoVersion2 && opts .defaultTimestamp {
@@ -1653,7 +1635,7 @@ type writeBatchFrame struct {
16531635 consistency Consistency
16541636
16551637 // v3+
1656- serialConsistency SerialConsistency
1638+ serialConsistency Consistency
16571639 defaultTimestamp bool
16581640 defaultTimestampValue int64
16591641
0 commit comments