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

Method nextSequence

db/sequence_allocator.go:175–188  ·  view source on GitHub ↗

Returns the next available sequence. If previously reserved sequences are available (s.last < s.max), returns one and increments s.last. If no previously reserved sequences are available, reserves new batch.

(ctx context.Context)

Source from the content-addressed store, hash-verified

173// and increments s.last.
174// If no previously reserved sequences are available, reserves new batch.
175func (s *sequenceAllocator) nextSequence(ctx context.Context) (sequence uint64, err error) {
176 s.mutex.Lock()
177 sequence, sequencesReserved, err := s._nextSequence(ctx)
178 s.mutex.Unlock()
179 if err != nil {
180 return 0, err
181 }
182 // If sequences were reserved, send notification to the release sequence monitor, to start the clock for releasing these sequences.
183 // Must be done after mutex is released.
184 if sequencesReserved {
185 s.reserveNotify <- struct{}{}
186 }
187 return sequence, nil
188}
189
190// _releaseCurrentBatch releases any unused sequences currently held by the allocator.
191// Writes unused sequence document while holding s.lock, shouldn't be used by high-throughput operations.

Callers 15

TestSequenceAllocatorFunction · 0.95
NextSequenceMethod · 0.80
DeleteRoleMethod · 0.80
UpdatePrincipalMethod · 0.80
assignSequenceMethod · 0.80
multiNodeUpdateFunction · 0.80

Calls 3

_nextSequenceMethod · 0.95
LockMethod · 0.45
UnlockMethod · 0.45