Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
David Martin edited this page Jan 30, 2017 · 1 revision

Sync Framework (fh.sync)

Sync Pages

Sync Terminology

Sync Protocol

The protocol used between the Sync Client and Sync Server.
See Sync Protocol for more details.

Sync Server

The Sync Server is a Node.js implemention of the server part of the Sync Protocol.
It is included in the fh-mbaas-api module. It:

Sync Client

The Sync Client is an implementation of the client part of the Sync Protocol
There are 3 Sync Client implementations available:

The Sync Client:

Sync Server Loop

The Sync Server Loop is a function that runs continuously in the Sync Server with a 500ms wait between each run.
Each run it iterates over all DataSet Clients to see if a DataSet should be synced from the DataSet Backend.

Sync Client Loop

The Sync Client Loop is a function that runs continuously in the Sync Client with a 500ms wait between each run.
Each run it iterates over all DataSet Clients to see if a DataSet should be synced with the Sync Server.

Sync Frequency

In the Sync Client, this is the frequency to check for updates from the Sync Server for a particular DataSet.
In the Sync Server, this is the frequency to check for updates from the DataSet Backend for a particular DataSet.

IMPORTANT: It is possible to configure the frequency differently on the client and server. However, the frequency should be the same to avoid issues where:

  • the client is calling more frequently than the server is checking for updates from the DataSet Backend, causing unnecessary traffic from the client

  • the client is calling less frequently than the server is checking for updates from the DataSet Backend, causing the server to think that client is no longer active and dropping its DataSet from the cache

DataSet

A DataSet is a collection of records being synchronized between 1 or more Sync Clients, the Sync Server and the DataSet Backend.

DataSet Backend

The system of record for data being syncrhronized between the Sync Client and the Sync Server.
It could be anything that provides an API that can be integrated with from the Sync Server e.g. a mysql database, a SOAP service.
The Sync Server exposes the Sync Server API for integrating with a DataSet Backend via DataSet Handlers

DataSet Handler

A DataSet Handler is a function for intergrating the Sync Server into a DataSet Backend.
There are many handlers for doing CRUDL actions on a DataSet and managing collisions between DataSet Records.
The default implementation of these handlers uses fh.db (MongoDB backed in an RHMAP MBaaS).
All of these handlers can be overriden. See the Sync Server API for details.

IMPORTANT: If you are overriding handlers, it is advised to override all handlers. This is to avoid unusual behaviour with some handlers using the default implementation and others using an overridden implementation.

DataSet Client

A DataSet Client is a configuration stored in the Sync Client & Sync Server for each DataSet that is actively syncing between the client & server.
It contains data such as:

DataSet Record

A DataSet Record is an individual record in a DataSet.
It contains:

  • the raw data that this record represents e.g. the Row values from a MySQL table

  • a Hash of the raw data

Hash

There are 2 types of Hash used in the Sync Protocol:

  • hash of an individual DataSet Record

    • this is used to compare individual records to see if they are different

  • hash of all DataSet Records for a particular DataSet Client

    • this is used to compare a clients set of records with the servers without having to iterate over all records