-
Notifications
You must be signed in to change notification settings - Fork 35
Home
-
Sync Overview <– TODO: port from CP, use as upstream
-
Sync Protocol <– TODO: port from google doc
-
Sync Server API <– TODO: port from CP, use as upstream
-
Sync Client API <– TODO: port from CP, use as upstream
The protocol used between the Sync Client and
Sync Server.
See Sync Protocol for more details.
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:
-
exposes the Sync Server API for integrating with a DataSet Backend
-
runs the Sync Server Loop, updating DataSets when updates from a DataSet Backend are detected
The Sync Client is an implementation of the client part of the
Sync Protocol
There are 3 Sync Client implementations available:
-
Javascript, in the FeedHenry Javascript SDK
-
Objective C, in the FeedHenry iOS SDK
-
Java, in the FeedHenry Android SDK
The Sync Client:
-
exposes the Sync Client API to the frontend for CRUDL actions against a DataSet
-
runs the Sync Client Loop, making a call to the Sync Server at the specified Sync Frequency for a particular DataSet.
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.
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.
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
A DataSet is a collection of records being synchronized between 1 or more Sync Clients, the Sync Server and the 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
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.
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:
-
the Sync Frequency of the DataSet
-
any query parameters to include when making calls to the DataSet Backend
-
the latest Hash of the DataSet Records
-
if a sync with the DataSet Backend is currently in progress
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
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
-