Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Main][Task]27742145: Change nonOverrideCfgs to be added only during initialization #2332

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/applicationinsights-cfgsync-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Refer to [our GitHub page](https://github.com/microsoft/ApplicationInsights-JS)
| onCfgChangeReceive | function<br>[Optional] | null | Overrides callback function to handle event details when changes are received via event listener. |
| overrideSyncFn | function<br>[Optional] | null | Overrides sync() function to broadcast changes. |
| overrideFetchFn | function<br>[Optional] | null | Overrides fetch function to get config from cfgUrl when cfgUrl is defined. |
| nonOverrideConfigs | NonOverrideCfg<br>[Optional] | {instrumentationKey: true, connectionString: true, endpointUrl: true } | When current instance is set with syncMode: `Receive`, config fields under nonOverrideConfigs will NOT be changed by any confif details sent out from other instances. |
| nonOverrideConfigs | NonOverrideCfg<br>[Optional] | {instrumentationKey: true, connectionString: true, endpointUrl: true } | When current instance is set with syncMode: `Receive`, config fields under nonOverrideConfigs will NOT be changed by any confif details sent out from other instances. NOTE: this config will be ONLY applied during initialization, so it won't be changed dynamically. |
| scheduleFetchTimeout | number<br>[Optional] | 30 mins | Identifies the time interval (in milliseconds) for fetching config details from cfgUrl when cfgUrl is defined. If set to 0, the fetch operation will only be called once during initialization. |


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ export class CfgSyncPluginTests extends AITestClass {
this.core.config.extensionConfig[this.identifier].syncMode = ICfgSyncMode.Receive;
this.core.config.extensionConfig[this.identifier].receiveChanges = true;
this.core.config.extensionConfig[this.identifier].blkCdnCfg = true;
this.core.config.extensionConfig[this.identifier].nonOverrideConfigs = {};

this.clock.tick(1);
targets = this.mainInst["_getDbgPlgTargets"]();
Assert.equal(targets[0], true, "auto sync should not be changed to false dynamically");
Assert.equal(targets[1], false, "receive changes should not be changed dynamically");
Assert.equal(targets[3], true, "blkCdnCfg changes should be changed dynamically");
Assert.deepEqual(targets[4], defaultNonOverrideCfg, "nonOverrideCfg changes should not be changed dynamically");
Assert.equal(patchEvnSpy.callCount, 3, "event dispatch should be called again");
curMainCfg = this.mainInst.getCfg();
Assert.deepEqual(curMainCfg, this.core.config, "main config should be set test2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class CfgSyncPlugin extends BaseTelemetryPlugin implements ICfgSyncPlugin
};

_self["_getDbgPlgTargets"] = () => {
return [_broadcastChanges, _receiveChanges, _evtName, _blkCdnCfg];
return [_broadcastChanges, _receiveChanges, _evtName, _blkCdnCfg, _nonOverrideConfigs];
};

function _initDefaults() {
Expand Down Expand Up @@ -179,7 +179,8 @@ export class CfgSyncPlugin extends BaseTelemetryPlugin implements ICfgSyncPlugin
_overrideSyncFn = _extensionConfig.overrideSyncFn;
_overrideFetchFn = _extensionConfig.overrideFetchFn;
_onCfgChangeReceive = _extensionConfig.onCfgChangeReceive;
_nonOverrideConfigs = _extensionConfig.nonOverrideConfigs;
_nonOverrideConfigs = _extensionConfig.nonOverrideConfigs; // override values should not be changed

_fetchTimeout = _extensionConfig.scheduleFetchTimeout;
_fetchFn = _getFetchFnInterface();
_retryCnt = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export interface ICfgSyncConfig {
*/
overrideFetchFn?: SendGetFunction;
/**
* When current instance is set with syncMode: `Receive`, config fields under nonOverrideConfigs will NOT be changed by any confif details sent out from other instances.
* When current instance is set with syncMode: `Receive`, config fields under nonOverrideConfigs will NOT be changed by any config details sent out from other instances.
* NOTE: this config will be ONLY applied during initialization, so it won't be changed dynamically
* @default {instrumentationKey:true,connectionString:true,endpointUrl:true}
*/
nonOverrideConfigs?: NonOverrideCfg;
Expand Down
Loading