Skip to content

BaseUniqueIDGenerator uses System.currentTimeMillis #3

@buko

Description

@buko

BaseUniqueIDGenerator uses System.currentTimeMillis to determine the current millisecond.

This makes it impossible to regenerate a sequence of IDs given a sequence of timestamps and calls to the IDGenerator. So this library can't be used in deterministic systems that need to replay a sequence of events and regenerate the exact same IDs. It also makes it impossible to write deterministic tests.

It would be nice if it was possible to pass a 'Clock' to the interface. The Clock might have a single method, 'currentTimeMillis()'. Custom implementations could provide their own Clock implementation which would provide for determinism. The default 'WallClock' could of course continue to use System.currrentTimeMillis() to get the wall time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions