MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / parseIntegerSequenceID

Function parseIntegerSequenceID

db/sequence_id.go:94–130  ·  view source on GitHub ↗
(str string)

Source from the content-addressed store, hash-verified

92}
93
94func parseIntegerSequenceID(str string) (SequenceID, error) {
95 if str == "" {
96 return SequenceID{}, nil
97 }
98 s := SequenceID{}
99 components := strings.Split(str, ":")
100 var err error
101 if len(components) == 1 {
102 // Just the internal sequence
103 s.Seq, err = ParseIntSequenceComponent(components[0], false)
104 } else if len(components) == 2 {
105 // TriggeredBy and InternalSequence
106 if s.TriggeredBy, err = ParseIntSequenceComponent(components[0], false); err != nil {
107 return SequenceID{}, err
108 }
109 if s.Seq, err = ParseIntSequenceComponent(components[1], false); err != nil {
110 return SequenceID{}, err
111 }
112 } else if len(components) == 3 {
113 if s.LowSeq, err = ParseIntSequenceComponent(components[0], false); err != nil {
114 return SequenceID{}, err
115 }
116 if s.TriggeredBy, err = ParseIntSequenceComponent(components[1], true); err != nil {
117 return SequenceID{}, err
118 }
119 if s.Seq, err = ParseIntSequenceComponent(components[2], false); err != nil {
120 return SequenceID{}, err
121 }
122 } else {
123 return SequenceID{}, base.HTTPErrorf(400, "Invalid sequence: %q", str)
124 }
125
126 if err != nil {
127 return SequenceID{}, base.HTTPErrorf(400, "Invalid sequence: %q", str)
128 }
129 return s, nil
130}
131
132func ParseIntSequenceComponent(component string, allowEmpty bool) (uint64, error) {
133 value := uint64(0)

Callers 5

TestParseSequenceIDFunction · 0.85
BenchmarkParseSequenceIDFunction · 0.85
setLastCheckpointSeqMethod · 0.85
ParsePlainSequenceIDFunction · 0.85
unmarshalIntSequenceMethod · 0.85

Calls 2

HTTPErrorfFunction · 0.92

Tested by 2

TestParseSequenceIDFunction · 0.68
BenchmarkParseSequenceIDFunction · 0.68