Fix hidden side effect in TableUpdateMetadata
stettix opened this issue · 0 comments
stettix commented
TableUpdateMetadata
has an apply
method that generates a random commit ID. This is bad for two reasons:
- It's easy to forget to pass a commit ID when creating a
TableUpdateMetadata
and then you'll get a random one instead. - It's not referentially transparent.
We should remove this apply
method and add an effectful constructor in CommitId
instead, and use this where appropriate. E.g. something like this:
object CommitId {
def create[F[_]](implicit F: Sync[F]): F[CommitId] =
F.delay(UUID.randomUUID()).map(uuid => CommitId(uuid.toString))
}
Tracking here as a separate issue as it touches quite a bit of code in core
(not in any particularly complex way though).