Decouple Scheduling from Workflow

We have a use case where we let users schedule certain tasks for them, schedule daily, weekly etc. We use simple time difference to calculate sleep period with in the workflow and for any changes in schedule, we the update timer, similar to the one in samples samples-java/src/main/java/io/temporal/samples/updatabletimer at main · temporalio/samples-java · GitHub

Now we also want to execute the same workflow(minus sleep) for an Event. We can pass a flag/property with a condition to skip the sleep :slight_smile: . but wondering if there is a cleaner way to decouple scheduling from workflow altogether.

We are hoping to use Temporal Schedule Workflows | Temporal Documentation , as it has nice features like Exclusions for skipping on holidays unlike Temporal Cron. Since Temporal Schedule is still experimental, we are not allowed to use in production.

Please suggest.

You can add a different signal type for that particular event. And the signal handler would make sure that the sleep is not called.

so instead of passing a flag/property in the workflow object to skip sleep logic in workflow method, you are suggesting adding a @SignalMethod which flips say a boolean flag to false, so when workflow method executes it skips the sleep logic?

Yes you are correct.