Add some more datasync docs
This commit is contained in:
parent
db50895459
commit
002cae6515
6 changed files with 77 additions and 6 deletions
34
docs/data/sync/watchers.rst
Normal file
34
docs/data/sync/watchers.rst
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
==========
|
||||
Watchers
|
||||
==========
|
||||
|
||||
A datasync "watcher" is responsible for checking a given system to see
|
||||
if any records are in need of sync (e.g. have changed recently).
|
||||
|
||||
If the given system has a SQL DB, and applicable tables include a
|
||||
"last modified" column, then the most common/simple way is for the
|
||||
watcher to simply query the table, looking for records which were
|
||||
modified since the last check. There are a couple of downsides to
|
||||
this approach:
|
||||
|
||||
* must query each table separately, to find all "changed" records
|
||||
* not possible to detect "deleted" records in this way
|
||||
|
||||
Rattail itself uses a different approach though. The Rattail DB
|
||||
includes a ``change`` table, which in normal circumstances is empty.
|
||||
If so configured, Rattail can insert records into this ``change``
|
||||
table whenever (almost) *any* data record is changed or deleted etc.
|
||||
Then a datasync watcher will look for records in the ``change`` table
|
||||
instead of having to query each applicable table separately. The
|
||||
watcher also removes ``change`` records as they are processed.
|
||||
|
||||
A similar effect can be achieved if the watched system has a SQL DB to
|
||||
which you can install (tables and) triggers. In this case you can
|
||||
create a new table (e.g. ``datasync``) and then add triggers for the
|
||||
various tables you need to watch. When any record is changed or
|
||||
deleted the trigger should add a record to your new ``datasync``
|
||||
table. Then the actual watcher can check your ``datasync`` table, and
|
||||
remove any found after they are processed.
|
||||
|
||||
Those are just the patterns used thus far; more are likely possible.
|
||||
Loading…
Add table
Add a link
Reference in a new issue