Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

sync 06

Nicolas Sebrecht edited this page Mar 17, 2016 · 2 revisions

No merge

With this design, there is no merge at all. The updates are blindly forwarded to the drivers by the engine.

This won't work. We have no idea what was changed since previous sync.


  {worker}                        {worker}                         {worker}
+---------+                     +----------+                     +----------+
|         |       (drives)      |          |      (drives)       |          |
|  driver |<--------------------|  engine  +-------------------->|  driver  |
|         |                     |          |                     |          |
+---------+                     +----------+                     +----------+

Use case

  • In the engine:
left.search(searchConditions) # Async
right.search(searchConditions) # Async

leftMessages = None
rightMessages = None

# Buggy but I don't care. Details can be fixed later.
# Might be better implemented with callbacks.
while (leftMessages is None) and (rightMessages is None):
  leftMessages = left.getSearchResult() # Async
  rightMessages = right.getSearchResult() # Async

  # No merge at all.
  if rightMessages is not None:
    left.updateMessages(leftMessages)
  if leftMessages is not None:
    right.updateMessages(leftMessages)

# Poll each side to forward full messages.
# Buggy and partial.
while (left.updateDone() is not True) and (right.updateDone() is not True):
  # What messages the left side need update?
  requestedMessages = left.requestFullMessages()
  # Fetch the messages.
  fullMessages = right.fetchMessages(requestedMessages)
  # Update the messages.
  left.updateMessages(fullMessages)

  • In a driver
TODO

Pros

  • No state backend at all!
  • Friendly on errors and hard kills by design.
  • The high-level code to update a repository can be written in a controller rather than in the drivers.

Cons

  • The sync engine must regularly poll both drivers to get a list of messages which need to be updated in order to fetch and forward them.
Clone this wiki locally