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

Support new extension upper schema version flag #361

Merged
merged 1 commit into from
May 24, 2022
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
18 changes: 3 additions & 15 deletions src/durableorchestrationbindinginfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LatestReplaySchema, ReplaySchema } from "./replaySchema";

/** @hidden */
export class DurableOrchestrationBindingInfo {
public readonly upperSchemaVersion: ReplaySchema;
public readonly upperSchemaVersionNew?: ReplaySchema;

constructor(
public readonly history: HistoryEvent[] = [],
Expand All @@ -14,18 +14,6 @@ export class DurableOrchestrationBindingInfo {
public readonly maximumShortTimerDuration?: string,
public readonly longRunningTimerIntervalDuration?: string,
public readonly defaultHttpAsyncRequestSleepTimeMillseconds?: number,
upperSchemaVersion = 0 // TODO: Implement entity locking // public readonly contextLocks?: EntityId[],
) {
// It is assumed that the extension supports all schemas in range [0, upperSchemaVersion].
// Similarly, it is assumed that this SDK supports all schemas in range [0, LatestReplaySchema].

// Therefore, if the extension supplies a upperSchemaVersion included in our ReplaySchema enum, we use it.
// But if the extension supplies an upperSchemaVersion not included in our ReplaySchema enum, then we
// assume that upperSchemaVersion is larger than LatestReplaySchema and therefore use LatestReplaySchema instead.
if (Object.values(ReplaySchema).includes(upperSchemaVersion)) {
this.upperSchemaVersion = upperSchemaVersion;
} else {
this.upperSchemaVersion = LatestReplaySchema;
}
}
public readonly upperSchemaVersion: ReplaySchema = ReplaySchema.V1 // TODO: Implement entity locking // public readonly contextLocks?: EntityId[],
) {}
}
20 changes: 18 additions & 2 deletions src/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "./classes";
import { DurableOrchestrationContext } from "./durableorchestrationcontext";
import { TaskOrchestrationExecutor } from "./taskorchestrationexecutor";
import { ReplaySchema } from "./replaySchema";
import { LatestReplaySchema, ReplaySchema } from "./replaySchema";

/** @hidden */
export class Orchestrator {
Expand Down Expand Up @@ -42,7 +42,23 @@ export class Orchestrator {

// The upper schema version corresponds to the maximum OOProc protocol version supported by the extension,
// we use it to determine the format of the SDK's output
const upperSchemaVersion: ReplaySchema = orchestrationBinding.upperSchemaVersion;
let upperSchemaVersion: ReplaySchema;

// represents the upper schema version suported by the extension
const extensionUpperSchemaVersion: ReplaySchema = orchestrationBinding.upperSchemaVersionNew
? orchestrationBinding.upperSchemaVersionNew
: orchestrationBinding.upperSchemaVersion;

// It is assumed that the extension supports all schemas in range [0, upperSchemaVersion].
// Similarly, it is assumed that this SDK supports all schemas in range [0, LatestReplaySchema].
// Therefore, if the extension supplies a upperSchemaVersion included in our ReplaySchema enum, we use it.
// But if the extension supplies an upperSchemaVersion not included in our ReplaySchema enum, then we
// assume that upperSchemaVersion is larger than LatestReplaySchema and therefore use LatestReplaySchema instead.
if (Object.values(ReplaySchema).includes(extensionUpperSchemaVersion)) {
upperSchemaVersion = extensionUpperSchemaVersion;
} else {
upperSchemaVersion = LatestReplaySchema;
}

// Initialize currentUtcDateTime
const decisionStartedEvent: HistoryEvent = Utils.ensureNonNull(
Expand Down