yorkie-team / yorkie

Yorkie is a document store for collaborative applications.
https://yorkie.dev
Apache License 2.0
785 stars 145 forks source link

Add check logic for conversion of `ClientDocInfo.Status` to the `UpdateClientInfoAfterPushPull` method. #555

Open emplam27 opened 1 year ago

emplam27 commented 1 year ago

What would you like to be added & Why is this needed:

The status of document changes as follow link(document-removal desing document) https://github.com/yorkie-team/yorkie/blob/main/design/document-removal.md#state-transition-of-document

 ┌──────────┐ Attach ┌──────────┐ Remove ┌─────────┐
 │ Detached ├───────►│ Attached ├───────►│ Removed │
 └──────────┘        └─┬─┬──────┘        └─────────┘
           ▲           │ │     ▲
           └───────────┘ └─────┘
              Detach     PushPull

The status is recorded in ClientDocInfo.Status and written to the DB via the UpdateClientInfoAfterPushPull method.

The status can be changed as follows

However, the following changes are not possible

We need to add check logic to return an error if it works incorrectly. There is no check logic to prevent invalid changes to the ClientDocInfo.Status in UpdateClientInfoAfterPushPull.

hackerwins commented 4 months ago

It would be good to introduce a helper function like state machine to check state updates. 🤔