@@ -192,6 +192,8 @@ const (
192192
193193type Consistency uint16
194194
195+ type SerialConsistency = Consistency
196+
195197const (
196198 Any Consistency = 0x00
197199 One Consistency = 0x01
@@ -202,6 +204,8 @@ const (
202204 LocalQuorum Consistency = 0x06
203205 EachQuorum Consistency = 0x07
204206 LocalOne Consistency = 0x0A
207+ Serial Consistency = 0x08
208+ LocalSerial Consistency = 0x09
205209)
206210
207211func (c Consistency ) String () string {
@@ -224,6 +228,10 @@ func (c Consistency) String() string {
224228 return "EACH_QUORUM"
225229 case LocalOne :
226230 return "LOCAL_ONE"
231+ case Serial :
232+ return "SERIAL"
233+ case LocalSerial :
234+ return "LOCAL_SERIAL"
227235 default :
228236 return fmt .Sprintf ("UNKNOWN_CONS_0x%x" , uint16 (c ))
229237 }
@@ -253,13 +261,21 @@ func (c *Consistency) UnmarshalText(text []byte) error {
253261 * c = EachQuorum
254262 case "LOCAL_ONE" :
255263 * c = LocalOne
264+ case "SERIAL" :
265+ * c = Serial
266+ case "LOCAL_SERIAL" :
267+ * c = LocalSerial
256268 default :
257269 return fmt .Errorf ("invalid consistency %q" , string (text ))
258270 }
259271
260272 return nil
261273}
262274
275+ func (c Consistency ) IsSerial () bool {
276+ return c == Serial || c == LocalSerial
277+
278+ }
263279func ParseConsistency (s string ) Consistency {
264280 var c Consistency
265281 if err := c .UnmarshalText ([]byte (strings .ToUpper (s ))); err != nil {
@@ -286,40 +302,35 @@ func MustParseConsistency(s string) (Consistency, error) {
286302 return c , nil
287303}
288304
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- }
305+ //type SerialConsistency = Consistency
306+ //
307+ //func (s SerialConsistency) ToString() string {
308+ // switch s {
309+ // case Serial:
310+ // return "SERIAL"
311+ // case LocalSerial:
312+ // return "LOCAL_SERIAL"
313+ // default:
314+ // return fmt.Sprintf("UNKNOWN_SERIAL_CONS_0x%x", uint16(s))
315+ // }
316+ //}
317+ //
318+ //func (s SerialConsistency) MarshalSerialText() (text []byte, err error) {
319+ // return []byte(s.String()), nil
320+ //}
321+ //
322+ //func (s *SerialConsistency) UnmarshalSerialText(text []byte) error {
323+ // switch string(text) {
324+ // case "SERIAL":
325+ // *s = Serial
326+ // case "LOCAL_SERIAL":
327+ // *s = LocalSerial
328+ // default:
329+ // return fmt.Errorf("invalid consistency %q", string(text))
330+ // }
331+ //
332+ // return nil
333+ //}
323334
324335const (
325336 apacheCassandraTypePrefix = "org.apache.cassandra.db.marshal."
0 commit comments