diff --git a/packages/test/src/test-workflows.ts b/packages/test/src/test-workflows.ts index 55220d9ee..8baf6d82e 100644 --- a/packages/test/src/test-workflows.ts +++ b/packages/test/src/test-workflows.ts @@ -76,13 +76,13 @@ function makeActivation( }; } -function makeUnblockTimer(timerId: string, timestamp: number = Date.now()): iface.coresdk.IWFActivation { - return makeActivation(timestamp, makeUnblockTimerJob(timerId)); +function makeFireTimer(timerId: string, timestamp: number = Date.now()): iface.coresdk.IWFActivation { + return makeActivation(timestamp, makeFireTimerJob(timerId)); } -function makeUnblockTimerJob(timerId: string): iface.coresdk.IWFActivationJob { +function makeFireTimerJob(timerId: string): iface.coresdk.IWFActivationJob { return { - timerFired: { timerId }, + fireTimer: { timerId }, }; } @@ -214,7 +214,7 @@ test('set-timeout', async (t) => { compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '0', startToFireTimeout: msToTs(100) })])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['slept']]); @@ -227,7 +227,7 @@ test('set-timeout-after-microtasks', async (t) => { compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '0', startToFireTimeout: msToTs(100) })])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['slept']]); @@ -261,7 +261,7 @@ test('tasks-and-microtasks', async (t) => { compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '0', startToFireTimeout: msToTs(0) })])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['script start'], ['script end'], ['promise1'], ['promise2'], ['setTimeout']]); @@ -281,7 +281,7 @@ test('trailing-timer', async (t) => { ); } { - const req = await activate(t, makeActivation(undefined, makeUnblockTimerJob('0'), makeUnblockTimerJob('1'))); + const req = await activate(t, makeActivation(undefined, makeFireTimerJob('0'), makeFireTimerJob('1'))); // Note that the trailing timer does not get scheduled since the workflow completes // after the first timer is triggered causing the second one to be dropped. compareCompletion(t, req, makeSuccess([makeCompleteWorkflowExecution(defaultDataConverter.toPayload('first'))])); @@ -303,7 +303,7 @@ test('promise-race', async (t) => { ); } { - const req = await activate(t, makeActivation(undefined, makeUnblockTimerJob('0'), makeUnblockTimerJob('1'))); + const req = await activate(t, makeActivation(undefined, makeFireTimerJob('0'), makeFireTimerJob('1'))); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [[1], [1], [1], [1], [20], ['wow']]); @@ -323,11 +323,11 @@ test('race', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess([])); } { - const req = await activate(t, makeUnblockTimer('1')); + const req = await activate(t, makeFireTimer('1')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [[1], [2], [3]]); @@ -340,7 +340,7 @@ test('importer', async (t) => { compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '0', startToFireTimeout: msToTs(10) })])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['slept']]); @@ -405,7 +405,7 @@ test('simple-query', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } { @@ -450,7 +450,7 @@ test('cancel-workflow', async (t) => { compareCompletion(t, req, makeSuccess([])); } { - const req = await activate(t, makeUnblockTimer('2')); + const req = await activate(t, makeFireTimer('2')); compareCompletion(t, req, makeSuccess([makeCompleteWorkflowExecution(defaultDataConverter.toPayload({ url }))])); } t.deepEqual(logs, [['Workflow cancelled'], ['Workflow cancelled'], ['Workflow cancelled']]); @@ -507,7 +507,7 @@ test('cancellation-scopes', async (t) => { compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '0', startToFireTimeout: msToTs(3) })])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion( t, req, @@ -519,7 +519,7 @@ test('cancellation-scopes', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('2')); + const req = await activate(t, makeFireTimer('2')); compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '3', startToFireTimeout: msToTs(3) })])); } { @@ -549,11 +549,11 @@ test('child-and-shield', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess([])); } { - const req = await activate(t, makeUnblockTimer('1')); + const req = await activate(t, makeFireTimer('1')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['Exception was propagated 👍'], ['Slept in shield 👍']]); @@ -573,7 +573,7 @@ test('partial-shield', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('1')); + const req = await activate(t, makeFireTimer('1')); compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '2', startToFireTimeout: msToTs(2) })])); } { @@ -588,11 +588,11 @@ test('partial-shield', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess([makeStartTimerCommand({ timerId: '4', startToFireTimeout: msToTs(1) })])); } { - const req = await activate(t, makeUnblockTimer('3')); + const req = await activate(t, makeFireTimer('3')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [['Workflow cancelled']]); @@ -612,11 +612,11 @@ test('shield-in-shield', async (t) => { ); } { - const req = await activate(t, makeUnblockTimer('1')); + const req = await activate(t, makeFireTimer('1')); compareCompletion(t, req, makeSuccess([])); } { - const req = await activate(t, makeUnblockTimer('0')); + const req = await activate(t, makeFireTimer('0')); compareCompletion(t, req, makeSuccess()); } t.deepEqual(logs, [ diff --git a/packages/worker/native/sdk-core b/packages/worker/native/sdk-core index ac936a9c1..ec360a5c9 160000 --- a/packages/worker/native/sdk-core +++ b/packages/worker/native/sdk-core @@ -1 +1 @@ -Subproject commit ac936a9c17acf15102c24a823a63629271917f1a +Subproject commit ec360a5c9f8ef2b274c545c04e4f9b66a6d1914f diff --git a/packages/workflow/src/internals.ts b/packages/workflow/src/internals.ts index 3717c448a..299a962e8 100644 --- a/packages/workflow/src/internals.ts +++ b/packages/workflow/src/internals.ts @@ -146,7 +146,7 @@ function timerIdToSeq(timerId: string | undefined | null) { } export class Activator implements WorkflowTaskHandler { - public startWorkflow(activation: iface.coresdk.IStartWorkflowTaskAttributes): void { + public startWorkflow(activation: iface.coresdk.IStartWorkflow): void { if (state.workflow === undefined) { throw new Error('state.workflow is not defined'); } @@ -163,17 +163,17 @@ export class Activator implements WorkflowTaskHandler { } } - public cancelWorkflow(_activation: iface.coresdk.ICancelWorkflowTaskAttributes): void { + public cancelWorkflow(_activation: iface.coresdk.ICancelWorkflow): void { state.cancelled = true; rootScopeCancel(new CancellationError('Workflow cancelled')); } - public timerFired(activation: iface.coresdk.ITimerFiredTaskAttributes): void { + public fireTimer(activation: iface.coresdk.IFireTimer): void { const { resolve } = consumeCompletion(timerIdToSeq(activation.timerId)); resolve(undefined); } - public timerCanceled(activation: iface.coresdk.ITimerCanceledTaskAttributes): void { + public cancelTimer(activation: iface.coresdk.ICancelTimer): void { const { scope } = consumeCompletion(timerIdToSeq(activation.timerId)); try { scope.cancel(new CancellationError('Timer cancelled')); @@ -182,7 +182,7 @@ export class Activator implements WorkflowTaskHandler { } } - public queryWorkflow(job: iface.coresdk.IQueryWorkflowJob): void { + public queryWorkflow(job: iface.coresdk.IQueryWorkflow): void { if (state.workflow === undefined) { throw new Error('state.workflow is not defined'); } @@ -208,7 +208,7 @@ export class Activator implements WorkflowTaskHandler { } } - public randomSeedUpdated(_activation: iface.coresdk.IRandomSeedUpdatedAttributes): void { + public updateRandomSeed(_activation: iface.coresdk.IUpdateRandomSeed): void { throw new Error('Not implemented'); } } @@ -224,20 +224,20 @@ export function activate(encodedActivation: Uint8Array, jobIndex: number): boole if (state.activator === undefined) { throw new Error('state.activator is not defined'); } - if (job.attributes === undefined) { - throw new Error('Expected job.attributes to be defined'); + if (job.variant === undefined) { + throw new Error('Expected job.variant to be defined'); } - const attrs = job[job.attributes]; - if (!attrs) { - throw new Error(`Expected job.${job.attributes} to be set`); + const variant = job[job.variant]; + if (!variant) { + throw new Error(`Expected job.${job.variant} to be set`); } // The only job that can be executed on a completed workflow is a query. // We might get other jobs after completion for instance when a single // activation contains multiple jobs and the first one completes the workflow. - if (state.completed && job.attributes !== 'queryWorkflow') { + if (state.completed && job.variant !== 'queryWorkflow') { return false; } - state.activator[job.attributes](attrs); + state.activator[job.variant](variant); return true; }