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

Timer support #9

Closed
kaibocai opened this issue Dec 6, 2023 · 0 comments
Closed

Timer support #9

kaibocai opened this issue Dec 6, 2023 · 0 comments
Assignees

Comments

@kaibocai
Copy link
Member

kaibocai commented Dec 6, 2023

The SDK should support creating timer inside the orchestration

end-to-end example

  it("should be able to run an single timer", async () => {
    const delay = 3
    const singleTimer: TOrchestrator = async function* (ctx: OrchestrationContext, startVal: number): any {
      yield ctx.createTimer(delay)
    };

    taskHubWorker.addOrchestrator(singleTimer);
    await taskHubWorker.start();

    const id = await taskHubClient.scheduleNewOrchestration(singleTimer);
    const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);

    const expectedCompletionSecond = state?.createdAt?.getTime()! + delay * 1000;
    const actualCompletionSecond = state?.lastUpdatedAt?.getTime();
    
    expect(state);
    expect(state?.name).toEqual(getName(singleTimer));
    expect(state?.instanceId).toEqual(id);
    expect(state?.failureDetails).toBeUndefined();
    expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
    expect(state?.createdAt).toBeDefined();
    expect(state?.lastUpdatedAt).toBeDefined();
    expect(expectedCompletionSecond).toBeLessThanOrEqual(actualCompletionSecond!);
  }, 31000);

Tested on local, already support.

Reference: #4

@kaibocai kaibocai mentioned this issue Dec 6, 2023
13 tasks
@kaibocai kaibocai self-assigned this Dec 19, 2023
@kaibocai kaibocai closed this as completed Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant