Before the action
waitFor checks your role, the step’s prerequisites, the allowed order and the
thread’s state. If everything is satisfied, it gives you a grant: permission
for one attempt at that step. If a prerequisite is still missing, it waits for
it until the timeout.
If waitFor throws or times out, don’t do the work.
The next report of that step on the same thread object is linked to the grant
automatically. A grant only covers the order and the parties. It can’t check
data you haven’t sent yet, so content rules are still checked when you report
the step.
After reporting the outcome
.failed() too. The step is sent once, and the call returns
when Threadify has checked it. If it broke the contract, the call throws with the
violation attached.
This tells you whether the work was allowed. It can’t undo the work. For that,
ask before acting.
Fresh approval for every attempt
Sometimes every attempt needs its own approval. Usemust succeed before each invocation:
finished step.
Recovery
You decided not to act. Release the grant:stepId. Wait again without reporting the step twice:
Go and Python
In Go, cancelling the
ctx cancels the wait. In Python, cancel the task.
With OpenTelemetry
If an operation is already traced, get the grant with the SDK, then put these attributes on the operation’s span instead of reporting a separate step:threadify.thread_idthreadify.step_namethreadify.invocation_id