_nextSequence reserves if needed, and then returns the next sequence
(ctx context.Context)
| 327 | |
| 328 | // _nextSequence reserves if needed, and then returns the next sequence |
| 329 | func (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. |
| 344 | func (s *sequenceAllocator) _reserveSequenceBatch(ctx context.Context) error { |
no test coverage detected