patriknw / akka-data-replication

Replication of CRDTs in Akka Cluster
Other
216 stars 18 forks source link

Add FWWMap and FWWRegister #78

Closed hseeberger closed 9 years ago

hseeberger commented 9 years ago

Not sure if this code duplication approach is a good idea, but we could always introduce common supertypes for the common things later.

patriknw commented 9 years ago

I think the same thing can be done with ordinary LWWRegister by replacing the default clock with a reverse clock. LWWRegister and LWWMap takes an optional clock parameter. We could add something like this to LWWRegister companion.

val reverseClock = new Clock {
  override def nextTimestamp(currentTimestamp: Long): Long =
    math.min(0L - System.currentTimeMillis(), currentTimestamp - 1)
}

WDYT?

hseeberger commented 9 years ago

Awesome trick! Much better than adding lots of LOC.

patriknw commented 9 years ago

Superseded by #80