nl_tokens: Process the sync request . It will - validate the request body via the requestInterceptor - check if the dataset client is stopped for sync - create or update the dataset client - process acknowledgements push each of them to the ackQueue - process pending changes push each of them to the pendingQueue - list any processed updates for the given client
pl_tokens: function sync ( datasetId , params , cb ) { debug ( '[%s] process sync request for the dataset' , datasetId ) ; var queryParams = params . query_params || { } ; var metaData = params . meta_data || { } ; var datasetClient = new DatasetClient ( datasetId , { queryParams : queryParams , metaData : metaData } ) ; debug ( '[%s] processing sync API request :: query_params = %j:: meta_data = %j' , datasetId , queryParams , metaData ) ; async . series ( { requestInterceptor : async . apply ( interceptors . requestInterceptor , datasetId , params ) , readDatasetClient : function checkDatasetclientStopped ( callback ) { syncStorage . readDatasetClient ( datasetClient . getId ( ) , function ( err , datasetClientJson ) { if ( err ) { return callback ( err ) ; } if ( datasetClientJson && datasetClientJson . stopped === true ) { return callback ( new Error ( 'sync stopped for dataset ' + datasetId ) ) ; } else { return callback ( null , datasetClientJson ) ; } } ) ; } } , function ( err , <mask> ) { if ( err ) { debugError ( '[%s] sync request returns error = %s %j' , datasetId , err , params ) ; return cb ( err ) ; } return processSyncAPI ( datasetId , params , results . readDatasetClient , cb ) ; } ) ; }