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

Method lastSequence

db/sequence_allocator.go:155–169  ·  view source on GitHub ↗

Retrieves the last allocated sequence. If there hasn't been an allocation yet by this node, retrieves the value of the _sync:seq counter from the bucket by doing an incr(0)

(ctx context.Context)

Source from the content-addressed store, hash-verified

153// Retrieves the last allocated sequence. If there hasn't been an allocation yet by this node,
154// retrieves the value of the _sync:seq counter from the bucket by doing an incr(0)
155func (s *sequenceAllocator) lastSequence(ctx context.Context) (uint64, error) {
156 s.mutex.Lock()
157 lastSeq := s.last
158 s.mutex.Unlock()
159
160 if lastSeq > 0 {
161 return lastSeq, nil
162 }
163 s.dbStats.SequenceGetCount.Add(1)
164 last, err := s.getSequence()
165 if err != nil {
166 return 0, fmt.Errorf("Couldn't get sequence from bucket: %w", err)
167 }
168 return last, err
169}
170
171// Returns the next available sequence.
172// If previously reserved sequences are available (s.last < s.max), returns one

Callers 7

newSequenceAllocatorFunction · 0.95
TestSequenceAllocatorFunction · 0.95
LastSequenceMethod · 0.80
StartOnlineProcessesMethod · 0.80
LastSequenceMethod · 0.80

Calls 5

getSequenceMethod · 0.95
ErrorfMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45
AddMethod · 0.45