Skip to content

[Workflow] DaprWorkflowContext create_timer method should accept a timedelta #625

@cgillum

Description

@cgillum

Describe the proposal

In DaprWorkflowContext the create_timer method is defined as follows:

def create_timer(self, fire_at: datetime) -> task.Task:

However, it would be more convenient to also support timedelta as a parameter type. Note that the undelrying Durable Task SDK already supports this:

def create_timer(self, fire_at: Union[datetime, timedelta]) -> Task:

The workaround is that developers must do the following:

ctx.create_timer(ctx.current_utc_datetime + SOME_TIME_DELTA)

This workaround is problematic because it can tempt users to violate code constraint rules if they accidentally use datetime.now(), which is non-deterministic, instead of ctx.current_utc_datetime.

Ideally, users could simply write the following:

ctx.create_timer(SOME_TIME_DELTA)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions