You cannot use a Temporal client from inside a workflow. You can’t use any network calls from a workflow or make any calls to anything external in any way. Workflows must be deterministic.
Yeah, true. But how can I achieve this flow:
I need to call from a workflow another wf/activity that will run after 48h.
I used sleep in activity but seems like Temporal thinks that activity died without a heartbeat.
So I am kindly asking about the proper way to implement delayed execution of workflow/activity called inside another workflow.
The idea is to have it on a background. If parent WF finished execution I need to cancel this activity/wf.
It’s like I have a happy case when parent wf finishes in 2 days, so I can cancel. If not this needs to be executed.
Not following exactly, but this is how parent/child works by default. When parent cancels/completes, child/activity cancels/completes, but it is configurable.
Yes, you can run a workflow or a schedule or anything you with a Temporal client from inside an activity
If you want to do start an activity after a certain amount of time, you sleep in the workflow before starting the activity. Same for child workflows.
Can the calling workflow remain open while this call is made, or do you want to complete the parent but still schedule this one? If you want the parent to complete without affecting this one, you can start a child workflow with parent close policy as abandon that sleeps 48h as its first step and then does work.
So you’re having trouble connecting a client or you can connect a client and create the schedule but are not seeing it occur. If you are having general client connection trouble, can you start a new thread? If you are having schedule trouble, look in the UI (or describe programmatically) and see when the next time to run is or if it ran.
ScheduleSpec.start_at is not the start time, it is the time which nothing will start before. You still have to provide calendars or intervals. See the create schedule dev guide and the ScheduleSpec API doc.