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

* cfg sync override

* update
This commit is contained in:
Karlie-777 2024-04-19 13:16:55 -07:00 коммит произвёл GitHub
Родитель 9375ed33ce
Коммит 7bcd35c5ea
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -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. |

Просмотреть файл

@ -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");

Просмотреть файл

@ -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() {
@ -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;

Просмотреть файл

@ -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;