@@ -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
@@ -201,6 +204,8 @@ const (
201204 All Consistency = 0x05
202205 LocalQuorum Consistency = 0x06
203206 EachQuorum Consistency = 0x07
207+ Serial Consistency = 0x08
208+ LocalSerial Consistency = 0x09
204209 LocalOne Consistency = 0x0A
205210)
206211
@@ -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 {
@@ -275,41 +292,6 @@ func ParseConsistencyWrapper(s string) (consistency Consistency, err error) {
275292 return
276293}
277294
278- type SerialConsistency uint16
279-
280- const (
281- Serial SerialConsistency = 0x08
282- LocalSerial SerialConsistency = 0x09
283- )
284-
285- func (s SerialConsistency ) String () string {
286- switch s {
287- case Serial :
288- return "SERIAL"
289- case LocalSerial :
290- return "LOCAL_SERIAL"
291- default :
292- return fmt .Sprintf ("UNKNOWN_SERIAL_CONS_0x%x" , uint16 (s ))
293- }
294- }
295-
296- func (s SerialConsistency ) MarshalText () (text []byte , err error ) {
297- return []byte (s .String ()), nil
298- }
299-
300- func (s * SerialConsistency ) UnmarshalText (text []byte ) error {
301- switch string (text ) {
302- case "SERIAL" :
303- * s = Serial
304- case "LOCAL_SERIAL" :
305- * s = LocalSerial
306- default :
307- return fmt .Errorf ("invalid consistency %q" , string (text ))
308- }
309-
310- return nil
311- }
312-
313295const (
314296 apacheCassandraTypePrefix = "org.apache.cassandra.db.marshal."
315297)
@@ -1441,7 +1423,7 @@ type queryParams struct {
14411423 values []queryValues
14421424 pageSize int
14431425 pagingState []byte
1444- serialConsistency SerialConsistency
1426+ serialConsistency Consistency
14451427 // v3+
14461428 defaultTimestamp bool
14471429 defaultTimestampValue int64
@@ -1530,7 +1512,7 @@ func (f *framer) writeQueryParams(opts *queryParams) {
15301512 }
15311513
15321514 if opts .serialConsistency > 0 {
1533- f .writeConsistency (Consistency ( opts .serialConsistency ) )
1515+ f .writeConsistency (opts .serialConsistency )
15341516 }
15351517
15361518 if f .proto > protoVersion2 && opts .defaultTimestamp {
@@ -1642,7 +1624,7 @@ type writeBatchFrame struct {
16421624 consistency Consistency
16431625
16441626 // v3+
1645- serialConsistency SerialConsistency
1627+ serialConsistency Consistency
16461628 defaultTimestamp bool
16471629 defaultTimestampValue int64
16481630
0 commit comments