Skip to content

Commit

Permalink
Fix back compat for idleTime (#12539)
Browse files Browse the repository at this point in the history
For more information about how to contribute to this repo, visit [this
page](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).

## Description

[PR#10179](#10179)
introduced back-compat issue with the `idleTime` property in summary
heuristics. The property was deprecated, but no functionality was added
to continue temporary support for the property before it was officially
removed.
  • Loading branch information
kian-thompson authored Oct 18, 2022
1 parent e7b3595 commit 349b969
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api-report/container-runtime.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export interface ISummaryConfigurationDisableSummarizer {
// @public (undocumented)
export interface ISummaryConfigurationHeuristics extends ISummaryBaseConfiguration {
// @deprecated (undocumented)
idleTime: number;
idleTime?: number;
maxIdleTime: number;
maxOps: number;
maxTime: number;
Expand Down
9 changes: 6 additions & 3 deletions packages/runtime/container-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@
"version": "2.0.0",
"broken": {
"VariableDeclaration_DefaultSummaryConfiguration": {
"forwardCompat": false
"forwardCompat": false,
"backCompat": false
},
"TypeAliasDeclaration_ISummaryConfiguration": {
"forwardCompat": false
"forwardCompat": false,
"backCompat": false
},
"InterfaceDeclaration_ISummaryConfigurationHeuristics": {
"forwardCompat": false
"forwardCompat": false,
"backCompat": false
},
"InterfaceDeclaration_IGeneratedSummaryStats": {
"backCompat": false
Expand Down
4 changes: 1 addition & 3 deletions packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export interface ISummaryConfigurationHeuristics extends ISummaryBaseConfigurati
* @deprecated Please move all implementations to {@link ISummaryConfigurationHeuristics.minIdleTime} and
* {@link ISummaryConfigurationHeuristics.maxIdleTime} instead.
*/
idleTime: number;
idleTime?: number;
/**
* Defines the maximum allowed time, since the last received Ack, before running the summary
* with reason maxTime.
Expand Down Expand Up @@ -297,8 +297,6 @@ export type ISummaryConfiguration =
export const DefaultSummaryConfiguration: ISummaryConfiguration = {
state: "enabled",

idleTime: 15 * 1000, // 15 secs.

minIdleTime: 0,

maxIdleTime: 30 * 1000, // 30 secs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export class SummarizeHeuristicRunner implements ISummarizeHeuristicRunner {
}

public get idleTime(): number {
if (this.configuration.idleTime !== undefined) {
return this.configuration.idleTime;
}
const maxIdleTime = this.configuration.maxIdleTime;
const minIdleTime = this.configuration.minIdleTime;
const weightedNumOfOps = getWeightedNumberOfOps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ describe("Runtime", () => {
};
const summaryConfig: ISummaryConfiguration = {
state: "enabled",
idleTime: 5000, // 5 sec (idle)
maxTime: 5000 * 12, // 1 min (active)
maxOps: 1000, // 1k ops (active)
minOpsForLastSummaryAttempt: 50,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe("Runtime", () => {

const defaultSummaryConfig: ISummaryConfigurationHeuristics = {
state: "enabled",
idleTime: 5000, // 5 sec (idle)
maxTime: 5000 * 12, // 1 min (active)
maxOps: 1000, // 1k ops (active)
minOpsForLastSummaryAttempt: 50,
Expand Down Expand Up @@ -315,6 +314,18 @@ describe("Runtime", () => {
assertAttemptCount(1, "should run");
assert(getLastAttempt() === "maxOps");
});

it("idleTime should take precedence", () => {
const idleTime = 100;
const minIdleTime = 0;
const maxIdleTime = 200;
initialize({ idleTime, minIdleTime, maxIdleTime });

assert.strictEqual(runner.idleTime, 100, "expect idleTime to take precedence when provided");

initialize({ minIdleTime, maxIdleTime });
assert.strictEqual(runner.idleTime, 200, "expect maxIdleTime when idleTime is not provided");
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ declare function get_current_VariableDeclaration_DefaultSummaryConfiguration():
declare function use_old_VariableDeclaration_DefaultSummaryConfiguration(
use: TypeOnly<typeof old.DefaultSummaryConfiguration>);
use_old_VariableDeclaration_DefaultSummaryConfiguration(
// @ts-expect-error compatibility expected to be broken
get_current_VariableDeclaration_DefaultSummaryConfiguration());

/*
Expand Down Expand Up @@ -1279,6 +1280,7 @@ declare function get_current_TypeAliasDeclaration_ISummaryConfiguration():
declare function use_old_TypeAliasDeclaration_ISummaryConfiguration(
use: TypeOnly<old.ISummaryConfiguration>);
use_old_TypeAliasDeclaration_ISummaryConfiguration(
// @ts-expect-error compatibility expected to be broken
get_current_TypeAliasDeclaration_ISummaryConfiguration());

/*
Expand Down Expand Up @@ -1352,6 +1354,7 @@ declare function get_current_InterfaceDeclaration_ISummaryConfigurationHeuristic
declare function use_old_InterfaceDeclaration_ISummaryConfigurationHeuristics(
use: TypeOnly<old.ISummaryConfigurationHeuristics>);
use_old_InterfaceDeclaration_ISummaryConfigurationHeuristics(
// @ts-expect-error compatibility expected to be broken
get_current_InterfaceDeclaration_ISummaryConfigurationHeuristics());

/*
Expand Down

0 comments on commit 349b969

Please sign in to comment.