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

Method _nextSequence

db/sequence_allocator.go:329–341  ·  view source on GitHub ↗

_nextSequence reserves if needed, and then returns the next sequence

(ctx context.Context)

Source from the content-addressed store, hash-verified

327
328// _nextSequence reserves if needed, and then returns the next sequence
329func (s *sequenceAllocator) _nextSequence(ctx context.Context) (sequence uint64, sequencesReserved bool, err error) {
330 if s.last >= s.max {
331 if err := s._reserveSequenceBatch(ctx); err != nil {
332 return 0, false, err
333 }
334 sequencesReserved = true
335 }
336 s.last++
337 sequence = s.last
338 s.dbStats.SequenceAssignedCount.Add(1)
339 s.dbStats.LastSequenceAssignedValue.Set(int64(sequence))
340 return sequence, sequencesReserved, nil
341}
342
343// Reserve a new sequence range, based on batch size. Called by nextSequence when the previously allocated sequences have all been used.
344func (s *sequenceAllocator) _reserveSequenceBatch(ctx context.Context) error {

Callers 2

nextSequenceMethod · 0.95

Calls 3

_reserveSequenceBatchMethod · 0.95
AddMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected