Generating an idempotent workflow
Various methods and systems for generating an idempotent workflow are described herein. In one example, a method includes detecting distributed code and identifying a boundary function in the distributed code. The method can also include separating the boundary function into a transition function, a non-idempotent function, and a reversion function. Additionally, the method can include transforming the non-idempotent function into an idempotent function by generating a flag corresponding to the non-idempotent function, wherein the flag indicates if the non-idempotent function has been executed. Furthermore, the method can include combining the transition function, the idempotent function, and the reversion function to form the idempotent workflow.
1. A method, comprising:
identifying a boundary function that executes at least a first portion of distributed code on a first computing device and at least a second portion of the distributed code on a second computing device different from the first computing device;
separating the boundary function into a plurality of sub-functions based, at least in part, on operating characteristics corresponding to each of the plurality of sub-functions, wherein a first sub-function of the plurality of sub-functions generated from the boundary function has a first operating characteristic and a second sub-function of the plurality of sub-functions generated from the boundary function has a second operating characteristic different from the first operating characteristic;
transforming the first sub-function of the plurality of sub-functions having the first operating characteristic to have the second operating characteristic different from the first operating characteristic to produce a single output value from multiple executions of the first sub-function of the plurality of sub-functions by storing a flag indicating whether the first sub-function of the plurality of sub-functions has been executed;
including code in the first sub-function of the plurality of sub-functions to enable the first sub-function of the plurality of sub-functions to execute only once; and
combining the plurality of sub-functions to form a workflow having the second operating characteristic based, at least in part, on the flag.
2. The method of claim 1 ,
wherein the first sub-function has a non-idempotent operating characteristic; and
wherein the second sub-function has an idempotent operating characteristic.
3. The method of claim 2 ,
wherein the plurality of sub-functions comprises a transition function that identifies a transition from the first computing device to the second computing device and a reversion function that terminates a session on the first computing device or the second computing device.
4. The method of claim 1 , further comprising:
storing the plurality of sub-functions in a persistent workflow database.
5. The method of claim 4 , further comprising:
storing an input array corresponding to the plurality of sub-functions in the persistent workflow database.
6. The method of claim 4 , further comprising:
generating an error code based on generating an error during execution of any of the plurality of sub-functions; and
storing the error code in the persistent workflow database.
7. The method of claim 4 , further comprising:
calculating a number of instructions in any of the plurality of sub-functions; and
storing the number of instructions in the persistent workflow database.
8. The method of claim 1 , further comprising:
returning an output value from a previous execution of any of the plurality of sub-functions based, at least in part, on a second flag indicating that any of the plurality of sub-functions have previously executed.
9. One or more computer-readable storage media to generate a workflow comprising a plurality of instructions that, when executed by a processor, cause the processor to:
identify a boundary function that executes at least a first portion of distributed code on a first computing device and at least a second portion of the distributed code on a second computing device different from the first computing device;
separate the boundary function into a plurality of sub-functions based, at least in part, on operating characteristics corresponding to each of the plurality of sub-functions, wherein a first sub-function of the plurality of sub-functions generated from the boundary function has a first operating characteristic and a second sub-function of the plurality of sub-functions generated from the boundary function has a second operating characteristic different from the first operating characteristic, wherein the plurality of sub-functions comprises a transition function that identifies a transition from the first computing device to the second computing device and a reversion function that terminates a session;
transform the first sub-function of the plurality of sub-functions having the first operating characteristic to have the second operating characteristic different from the first operating characteristic to produce a single output value from multiple executions of the first sub-function of the plurality of sub-functions by storing a flag indicating whether the first sub-function of the plurality of sub-functions has been executed; and
combine the plurality of sub-functions to form a workflow having the second operating characteristic based, at least in part, on the flag.
10. The one or more computer-readable storage media of claim 9 , wherein the instructions cause the processor to include in the first sub-function of the plurality of sub-functions to enable the first sub-function of the plurality of sub-functions to execute only once.
11. The one or more computer-readable storage media of claim 9 , wherein the instructions cause the processor to store the plurality of sub-functions in a persistent workflow database.
12. The one or more computer-readable storage media of claim 11 , wherein the instructions cause the processor to store an input array corresponding to the plurality of sub-functions in the persistent workflow database.
13. The one or more computer-readable storage media of claim 11 , wherein the instructions cause the processor to:
generate an error code based on generating an error during execution of any of the plurality of sub-functions; and
store the error code in the persistent workflow database.
14. The one or more computer-readable storage media of claim 11 , wherein the instructions cause the processor to:
return an output value from a previous execution of any of the plurality of sub-functions based, at least in part, on a second flag indicating that any of the plurality of sub-functions have previously executed.
15. A system for generating a workflow, comprising:
one or more storage devices to store executable code; and
one or more processing devices to execute the executable code to:
identify a boundary function that executes at least a first portion of distributed code on a first computing device and at least a second portion of the distributed code on a second computing device different from the first computing device;
separate the boundary function into a plurality of sub-functions based, at least in part, on operating characteristics corresponding to each of the plurality of sub-functions, wherein a first sub-function of the plurality of sub-functions generated from the boundary function has a first operating characteristic and a second sub-function of the plurality of sub-functions generated from the boundary function has a second operating characteristic different from the first operating characteristic;
transform the first sub-function of the plurality of sub-functions having the first operating characteristic to have the second operating characteristic different from the first operating characteristic to produce a single output value from multiple executions of the first sub-function of the plurality of sub-functions by storing a flag indicating whether the first sub-function of the plurality of sub-functions has been executed;
include code in the first sub-function of the plurality of sub-functions to enable the first sub-function of the plurality of sub-functions to execute only once; and
combine the plurality of sub-functions to form a workflow having the second operating characteristic based, at least in part, on the flag.
16. The system of claim 15 , wherein the plurality of sub-functions comprises a transition function that identifies a transition from the first computing device to the second computing device and a reversion function that terminates a session.
17. The system of claim 15 , wherein the one or more processing devices execute the executable code further to store the plurality of sub-functions in a persistent workflow database.