yorkie-team/yorkie

Refactor the counter with generics

highcloud100 opened this issue · 0 comments

What would you like to be added:

Convert the raw types to generics in counter implementation.

https://github.com/yorkie-team/yorkie/blob/main/pkg/document/crdt/counter.go
https://github.com/yorkie-team/yorkie/blob/main/pkg/document/json/counter.go

Why is this needed:

Currently LongCnt, IntegerCnt types can be used as counter.
To support both types, there is many duplicated code in counter.
Moreover interface{} is used for supporting arbitrary type in crdt.Counter.
This interface{ } can spread and produce continuous bad results.

type Counter struct {
valueType CounterType
value interface{}
createdAt *time.Ticket
movedAt *time.Ticket