New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic definition and evaluation of states machine #9
Comments
Yes, it is. I would need a bit more details on your use-case to provide an
ideal path forward.
My use-case in the past was that the state machines were pre-defined, but
you could update the JSON itself backing the state machine and use hot code
reloading to update the gen_statem module.
…On Sat, Jan 9, 2021 at 3:39 PM Daya Sharma ***@***.***> wrote:
Using something like States Language editor and resulting json output, is
it possible to dynamically (at runtime) define state machines and have the
state machine executed/evaluated?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABGNLKZQ2QHXTXR5QH5KGDSZDEKLANCNFSM4V34MUIA>
.
|
Thanks for the reply @entone my use case is a logged in User using some Editor (like states-language editor) is able to define a State machine with all the steps, branching logic and callouts (webhooks). The system/application will then run one or more executions of this user defined state machine and generate report on them. Obviously as you can make out there will be a Schema based on the business domain which will control the possible state machines that can be generated. Do you think this kind of runtime creation and execution of state machines is easy enough to implement states_language? or will it require too much arm twisting? |
Not at all, I think it is quite doable. My approach has been to create a
Macro that will define the StatesLanguage implementation, the macro should
accept the JSON file or Map structure and generate a module at runtime, you
can then start a process based on the compiled module.
I have implemented something very similar for an IVR system, the original
inspiration for the project, however I'm not able to share that code.
It will come down to using something along the lines of
https://hexdocs.pm/elixir/Code.html#compile_string/2 to compile the module,
and starting that as a Task or under a supervision tree.
…On Mon, Jan 11, 2021 at 1:57 PM Daya Sharma ***@***.***> wrote:
Thanks for the reply @entone <https://github.com/entone> my use case is a
logged in User using some Editor (like states-language editor) is able to
define a State machine with all the steps, branching logic and callouts
(webhooks). The system/application will then run one or more executions of
this user defined state machine and generate report on them.
Obviously as you can make out there will be a Schema based on the business
domain which will control the possible state machines that can be generated.
Do you think this kind of runtime creation and execution of state machines
is easy enough to implement states_language? or will it require too much
arm twisting?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABGNLMO2Y3BLUZJXXO56FDSZNJ4JANCNFSM4V34MUIA>
.
|
Right that's one high level interface to the internals, and I hope you meant something along these lines, right? defmodule MyModule do
use StatesLanguage, data: %{state1: %{}, state2: %{}}
end but as that is compile time still, I am looking for some place in code base where that compile time configuration is executed to interpret the graph into a |
You will need to use Code.compile_string in order to do it at runtime, or
another one of the functions that will compile a module, and pass in the
data by either writing the JSON to a file, or using something like
Code.compile_quoted to pass in a map to your macro.
…On Mon, Jan 11, 2021 at 4:48 PM Daya Sharma ***@***.***> wrote:
the macro should accept the JSON file or Map structure and generate a
module at runtime, you
can then start a process based on the compiled module.
Right that's one high level interface to the internals, and I hope you
meant something along these lines, right?
defmodule MyModule do
use StatesLanguage, data: %{state1: %{}, state2: %{}}
end
but as that is compile time still, I am looking for some place in code
base where that compile time configuration is executed to interpret the
graph into a gen_statem process. Could you please help me with a pointer
to that module/line?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABGNLOOUNIRT46S2FVGCQ3SZN53BANCNFSM4V34MUIA>
.
|
@daya not sure if you ever figured this out, but I put together an example, https://github.com/entropealabs/states_language_runtime |
Using something like States Language editor and resulting json output, is it possible to dynamically (at runtime) define state machines and have the state machine executed/evaluated?
The text was updated successfully, but these errors were encountered: