Temporal .NET – Deterministic Workflow Authoring in .NET
For those not familiar with workflows as code, a workflow is a method that is executed in a way that can&#x27;t fail—each step the program takes is persisted, so that if execution is interrupted (the process crashes or machine loses power), execution will be continued on a new machine, from the same step, with all local&#x2F;instance variables, threads, and the call stack intact. It also transparently retries network requests that fail.<p>So it&#x27;s great for any code that you want to ensure reliably runs, but having methods that can&#x27;t fail also opens up new possibilities, like you can:<p>- Write a method that implements a subscription, charging a card and sleeping for 30 days in a loop. The `await Workflow.DelayAsync(TimeSpan.FromDays(30))` is transparently translated into a persisted timer that will continue executing the method when it goes off, and in the meantime doesn&#x27;t consume resources beyond the timer record in the database.<p>- Store data in variables instead of a database, because you can trust that the variables will be accurate for the duration of the method execution, and execution spans server restarts!<p>- Write methods that last indefinitely and model an entity, like a customer, that maintains their loyalty program points in an instance variable. (Workflows can receive RPCs called Signals and Queries for sending data to the method (&quot;User just made a purchase for $30, so please add 300 loyalty points&quot;) and getting data out from the method (&quot;What&#x27;s the user&#x27;s points total?&quot;).<p>- Write a saga that maintains consistency across services &#x2F; data stores without manually setting up choreography or orchestration, with a simple try&#x2F;catch statement. (A workflow method is like automatic orchestration.)