'use strict';

var cc = require('config-chain');

var autoconfig = function(overrides) {
  var config = cc(overrides).add({
    IP: process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0',
    PORT: process.env.FH_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8001,
    dataTopicPrefix: ':cloud:data',
    persistentStore: process.env.WFM_USE_MEMORY_STORE !== "true",
    syncOptions: {
      "sync_frequency" : 5,
      "storage_strategy": "dom",
      "do_console_log": false
    }
  });
  return config;
};

module.exports = autoconfig();
'use strict';

var cc = require('config-chain');

/**
 * The sync frequency to be passed to fh-wfm-sync.
 * Sync frequency is set individually for the client and the server.
 * * On the client the setting is named `sync_frequency`.
 * * On the server the setting is named `syncFrequency`.
 * It is recommended that these settings share the same value.
 */
var SYNC_FREQUENCY = 5;

var autoconfig = function(overrides) {
  var config = cc(overrides).add({
    IP: process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0',
    PORT: process.env.FH_PORT || process.env.OPENSHIFT_NODEJS_PORT || 8001,
    dataTopicPrefix: ':cloud:data',
    persistentStore: process.env.WFM_USE_MEMORY_STORE !== "true",
    syncOptions: {
      "syncFrequency": SYNC_FREQUENCY,
      "sync_frequency" : SYNC_FREQUENCY,
      "storage_strategy": "dom",
      "do_console_log": false
    }
  });
  return config;
};

module.exports = autoconfig();
Update server `syncFrequency` value to match client `sync_frequency`
Update server `syncFrequency` value to match client `sync_frequency`

Currently the server-side dataset sync frequencies are set to 10 seconds
whereas the client-side dataset sync frequencies are set to 5 seconds.

Having differing sync frequencies can cause unnecessary load on the
server, causing a full sync to be performed twice for each server-side
sync loop frequency.

This change adds the `syncFrequency` option which will default all
server-side datasets to sync every 5 seconds also.

The multiple sync issue has been documented from the following two
issues:

* FH-3018
* FH-3062
