Next produces the next KSUID in the sequence, or returns an error if the sequence has been exhausted.
()
| 29 | // Next produces the next KSUID in the sequence, or returns an error if the |
| 30 | // sequence has been exhausted. |
| 31 | func (seq *Sequence) Next() (KSUID, error) { |
| 32 | id := seq.Seed // copy |
| 33 | count := seq.count |
| 34 | if count > math.MaxUint16 { |
| 35 | return Nil, errors.New("too many IDs were generated") |
| 36 | } |
| 37 | seq.count++ |
| 38 | return withSequenceNumber(id, uint16(count)), nil |
| 39 | } |
| 40 | |
| 41 | // Bounds returns the inclusive min and max bounds of the KSUIDs that may be |
| 42 | // generated by the sequence. If all ids have been generated already then the |