TimeBasedEpochGenerator (UUIDv7) can't be provided a `UUIDClock`
Frozenlock opened this issue · 5 comments
Contrary to TimeBasedGenerator
, it looks like TimeBasedEpochGenerator
can't be provided with a UUIDTimer
.
I might be mistaken, but as far as I can tell this means it's impossible to generate a UUIDv7 with a particular timestamp.
True. But looking at code (it's been a while since I looked into it), I think what is really missing is the underlying UUIDClock
(I changed title to indicate that) -- UUIDTimer
itself is bit of an overkill needed to support 100 nanos
virtual granularity and uniqueness.
Having said that it looks like TimeBasedEpochGenerator
should indeed use UUIDClock
and allow construction with custom one.
I'd be happy to help if you or anyone else wanted to try creating a PR for adding use of UUIDClock
(including new factory method(s) in Generators
).
Otherwise I'll keep this as something I may take up in future if I have time (there's bit of backlog for all Jackson-related work but I try to help with PRs as the highest priority work I do).
@Frozenlock Created PR #80; will merge. If you have a chance to check it out I could release 4.3.0, but wanted to give a chance to verify first.
NOTE: even when giving UUIDClock
with static timestamp, UUID
s generated are unique as mandated by the spec.
So depending on use case this may or may not do what you want.
Please let me know either way.
Thank you very much!
I'll try to test it before the end of the week.
I'm having some issues compiling locally, so you should go ahead and deploy whenever you're ready.
I'm a little confused by your comment related to the Ethernet address; my rudimentary knowledge of UUID v7 didn't contain anything related to location. But I know very little on the subject...
@Frozenlock good catch, updated javadoc, was a copy-paste problem.