ReleaseSequence writes an unused sequence document, used to notify sequence buffering that a sequence has been allocated and not used. Sequence is stored as the document body to avoid null doc issues.
(ctx context.Context, sequence uint64)
| 400 | // ReleaseSequence writes an unused sequence document, used to notify sequence buffering that a sequence has been allocated and not used. |
| 401 | // Sequence is stored as the document body to avoid null doc issues. |
| 402 | func (s *sequenceAllocator) releaseSequence(ctx context.Context, sequence uint64) error { |
| 403 | key := fmt.Sprintf("%s%d", s.metaKeys.UnusedSeqPrefix(), sequence) |
| 404 | body := make([]byte, 8) |
| 405 | binary.LittleEndian.PutUint64(body, sequence) |
| 406 | _, err := s.datastore.AddRaw(key, UnusedSequenceTTL, body) |
| 407 | if err != nil { |
| 408 | return err |
| 409 | } |
| 410 | s.dbStats.SequenceReleasedCount.Add(1) |
| 411 | base.DebugfCtx(ctx, base.KeyCRUD, "Released unused sequence #%d", sequence) |
| 412 | return nil |
| 413 | } |
| 414 | |
| 415 | // releaseSequenceRange writes a binary document with the key _sync:unusedSeqs:fromSeq:toSeq. |
| 416 | // fromSeq and toSeq are inclusive (i.e. both fromSeq and toSeq are unused). |
no test coverage detected