Class: ConfigClient

Config Client

This client provides run-time access to Finsemble's configuration. See Understanding Finsemble's Configuration for a configuration overview.

Methods

get
(params, callback)

clients/configClient.js, line 58

Get all or a portion of the configuration from the Config Service. Typically this function is used to return Finsemble configuration (e.g., "finesemble.components"); however, if can also return all or part of the OpenFin manifest which contains the Finsemble config property. If no configReference parameter is passed in (i.e., only the callback parameter is specified), then the complete manifest object is returned (including manifest.finsemble).

Name Type Description
params object optional

field property indentifies specific config to return

callback function

callback function(error, data) to get the configuration data

Example
FSBL.Clients.ConfigClient.get({ field: "finsemble" },function(err, finsemble) {
		if (!err) {
			finsembleConfig = finsemble;
		} else {
			console.error("failed to get finsemble configuration");
		}
});

FSBL.Clients.ConfigClient.get({ field: "finsemble.isAuthEnabled" }, function(err, isAuthEnabled) {
		var authorizationOn = isAuthEnabled;
});

FSBL.Clients.ConfigClient.get(callback); // returns the complete manifest containing the finsemble property
FSBL.Clients.ConfigClient.get(null, callback); // alternate form; returns the complete manifest containing the finsemble property
FSBL.Clients.ConfigClient.get({}, callback); // alternate form; returns the complete manifest containing the finsemble property
FSBL.Clients.ConfigClient.get({ field: "finsemble.components" }, callback);
FSBL.Clients.ConfigClient.get({ field: "finsemble.services" }, callback);
FSBL.Clients.ConfigClient.get({ field: "finsemble.components" },callback);
FSBL.Clients.ConfigClient.get({ field: "finsemble.assimilation.whitelist" }, callback);
FSBL.Clients.ConfigClient.get({ field: "runtime.version",callback) }; // returns the manifest's runtime.version property

processAndSet
(params)

clients/configClient.js, line 150

Dynamically set config values within the Finsemble configuration. New config properties may be set or existing ones modified. Note that configuration changes will not necessarily dynamically modify the components or services that use the corresponding configuration—it depends if the component or service handles the corresponding change notifications (either though PubSub or the config's DataStore). Also, these changes do not persist in any config files.

Special Note: Anytime config is set using this API, the newConfig along with the updated manifest will by published to the PubSub topic "Config.changeNotification". To get these notifications, any component or service can subscribe to the topic. An example is shown below.

Special Note: Anytime config is set using this API, the dataStore underlying configuration Finsemble-Configuration-Store will also be updated. To get these dataStore events, a listener can be set as shown in the example below. However, any config modifications made directly though the DataStore will not result in corresponding PubSub notifications.

Name Type Description
params object
Name Type Description
newConfig object

provides the configuration properties to add into the existing configuration under manifest.finsemble. This config must match the Finsembe config requirements as described in Understanding Finsemble's Configuration. It can include importConfig references to dynamically fetch additional configuration files.

overwrite boolean optional

if true then overwrite any preexisting config with new config (can only set to true when running from same origin, not cross-domain); if false then newConfig must not match properties of existing config, including service and component configuration.

replace boolean optional

true specifies any component or service definitions in the new config will place all existing non-system component and service configuration

Examples
// Examples using processAndSet()
FSBL.Clients.ConfigClient.processAndSet({ newConfig: { myNewConfigField: 12345 }, overwrite: false});
FSBL.Clients.ConfigClient.processAndSet(
{
	newConfig: {
		"myNewConfigField": 12345,
		"myNewConfigObject": {
			A: "this is a test",
			B: "more test"
		},
		"importConfig": [
			"$applicationRoot/configs/application/test.json",
		]
	},
	overwrite: true,
 replace: false,
},
	function (err, finsemble) {
		if (err) {
			console.error("ConfigClient.set", err);
		} else {
			console.log("new finsemble config", finsemble);
		}
	}
);
// example subscribing to PubSub to get notifications of dynamic updates
RouterClient.subscribe("Config.changeNotification", function (err, notify) {
		console.log("set notification", notify.data.newConfig, notify.data.finsemble);
	});
// example using DataStore to get notifications of dynamic updates
DistributedStoreClient.getStore({ store: 'Finsemble-Configuration-Store', global: true }, function (err, configStore) {
		configStore.addListener({ field: "finsemble" }, function (err, newFinsembleConfig) {
			console.log("new manifest.finsemble configuration", newFinsembleConfig);
		});
});