Share
Embed
A tale of offline support an conflict resolution
Mobile devices are not always connected to a reliable Internet connection, but that does not matter that our apps should stope working if they are offline. In this talk I'll explain some approaches the Wunderlist team decided to take in order to provide full offline support.
Antonio J. Consuegra
February 27, 2016
Transcript
122 slides
-
Who am I? Antonio J. Consuegra Senior Software Engineer @
Microsoft @aconsuegra +AntonioConsuegra -
What is this talk NOT about? • RxJava • Testing
• Clean Architecture -
What IS this talk about? • Offline support matters, a
lot. • How to synchronise offline data. -
What IS this talk about? • Offline support matters, a
lot. • How to synchronise offline data. • How to resolve conflicts. -
Handle offline status like a Pro • Never, never block
the user. • Only a few calls should require being online. -
Handle offline status like a Pro • Never, never block
the user. • Only a few calls should require being online. • Most of user’s actions can be retried when online. -
How can you retry API calls? • Queue them (Priority
Job Queue, Job Scheduler, etc.) -
• Queue them (Priority Job Queue, Job Scheduler, etc.) •
Save only the last state of an entity… How can you retry API calls? -
• Queue them (Priority Job Queue, Job Scheduler, etc.) •
Save only the last state of an entity… • Save the current “sync” state. & How can you retry API calls? -
Sync state public class Entity { private enum SyncState
{ DIRTY, SYNCING, SYNCED } private SyncState syncState = SyncState.DIRTY; public Entity() { … } public SyncState getSyncState() { … } public void setSyncState(SyncState syncState) { … } } -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Sync state Note text = “Hello” state = SYNCED Note
text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY Online? YES Note text = “Hey Yo” state = SYNCING Some retry logic Success? Note text = “Hey Yo” state = SYNCED Note text = “Hey Yo” state = DIRTY YES NO NO ☁ -
Local ID & Online ID • At creation time, a
local_id is assigned to each entity. • When the entity is synced, it receives an online_id. • Children have to use local_id or online_id to identify its parent. -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
Flush dirty entities Root User List Task Subtask Comment Reminder
… IF entity is DIRTY ELSE REPEAT with child/sibling SET state to SYNCING PUSH entity to API IF success SET state to SYNCED IF onlineId was NULL UPDATE parentId in children REPEAT with child/sibling ELSE SET state to DIRTY REPEAT with child/sibling -
All right, but… • The proposed approach works fine for
one user/device. • We have to add a revision to each entity. • Every time an entity is updated, its revision is updated by the API. -
Revisions ☁ Task title = “Hello” localId = 1 Task
title = “Hello” localId = 1 onlineId = 1 revision = 1 HTTP POST 201 OK Case 1: Create a new entity -
Revisions ☁ Task title = “Hello” localId = 1 Task
title = “Hello” localId = 1 onlineId = 1 revision = 1 HTTP POST 201 OK Case 1: Create a new entity -
Revisions ☁ Task title = “Hello” localId = 1 Task
title = “Hello” localId = 1 onlineId = 1 revision = 1 HTTP POST 201 OK Case 1: Create a new entity -
Revisions ☁ Task title = “Hello” localId = 1 Task
title = “Hello” localId = 1 onlineId = 1 revision = 1 HTTP POST 201 OK Case 1: Create a new entity -
Revisions ☁ Task title = “Hello” localId = 1 Task
title = “Hello” localId = 1 onlineId = 1 revision = 1 HTTP POST 201 OK Case 1: Create a new entity -
Revisions ☁ Case 2: Update an entity Task title =
“Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 HTTP PATCH 200 OK -
Revisions ☁ Case 2: Update an entity Task title =
“Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 HTTP PATCH 200 OK -
Revisions ☁ Case 2: Update an entity Task title =
“Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 HTTP PATCH 200 OK -
Revisions ☁ Case 2: Update an entity Task title =
“Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 HTTP PATCH 200 OK -
Revisions ☁ Case 2: Update an entity Task title =
“Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 HTTP PATCH 200 OK -
Revisions ☁ Case 3: Delete an entity Task onlineId =
1 revision = 2 HTTP DELETE 200 OK -
Revisions ☁ Case 3: Delete an entity Task onlineId =
1 revision = 2 HTTP DELETE 200 OK -
Revisions ☁ Case 3: Delete an entity Task onlineId =
1 revision = 2 HTTP DELETE 200 OK -
Revisions ☁ Case 3: Delete an entity Task onlineId =
1 revision = 2 HTTP DELETE 200 OK -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4: Sync new entities Task title =
“Hello” localId = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 Task title = “Hello” localId = 1 onlineId = 1 revision = 1 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4a: Sync updated entities Task title =
“Hello” onlineId = 1 revision = 1 Task title = “Hello” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 1 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Revisions ☁ Case 4b: Sync updated entities Task title =
“Hey Yo” onlineId = 1 revision = 2 Task title = “Hey Yo” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 2 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 ⚡ -
Conflicts ☁ Task title = “Beer!” onlineId = 1 revision
= 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts ☁ ⚡ Task title = “Beer!” onlineId = 1
revision = 3 Task title = “Beer!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 3 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Buuu!!” onlineId = 1 revision = 4 Task title = “Beer!” starred = TRUE revision = 3 409 ERROR Task title = “Buuu!!” starred = TRUE revision = 4 Task title = “Buuu!!” starred = TRUE revision = 5 Task title = “Buuu!!” starred = TRUE revision = 5 -
Conflicts Resolution • The API returns 409 when the client
needs to fix a conflict. • Each entity holds a reference to the modified fields. • All platforms use the same algorithm to solve conflicts, we call it ThreeWayMergeResolver. -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY -
ThreeWayMergeResolver IF entity has conflict GET entity from API IF
success FOR each field in entity IF field was modified locally UPDATE field with local value SET state to DIRTY ELSE IF error code IS 404 DELETE entity locally ELSE RETRY