rattail.datasync.watchers

DataSync Watchers

class rattail.datasync.watchers.DataSyncWatcher(config, key, dbkey=None, **kwargs)[source]

Base class for all DataSync watchers.

get_changes(lastrun)[source]

This must be implemented by the subclass. It should check the source database for pending changes, and return a list of rattail.db.model.DataSyncChange instances representing the source changes.

localize_lastrun(session, lastrun)[source]

Calculates a timestamp using lastrun as the starting point, but also taking into account a possible (?) time drift between the local and “other” server.

process_changes(session, changes)[source]

Process (consume) a batch of changes.

prune_changes(keys)[source]

Prune change records from the source database, if relevant.

setup()[source]

This method is called when the watcher thread is first started.

class rattail.datasync.watchers.ErrorTestWatcher(config, key, dbkey=None, **kwargs)[source]

Watcher which always raises an error when attempting to get changes. Useful for testing error handling etc.

get_changes(lastrun)[source]

This must be implemented by the subclass. It should check the source database for pending changes, and return a list of rattail.db.model.DataSyncChange instances representing the source changes.

class rattail.datasync.watchers.NullWatcher(config, key, dbkey=None, **kwargs)[source]

Null watcher, will never actually check for or report any changes.