Skip to content
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

How To Use dynamic Stateless #554

Open
Mr-Mohammad opened this issue Dec 12, 2023 · 5 comments
Open

How To Use dynamic Stateless #554

Mr-Mohammad opened this issue Dec 12, 2023 · 5 comments

Comments

@Mr-Mohammad
Copy link

Hi,
What solution do you have for me to use stateless dynamically?

@mclift
Copy link
Member

mclift commented Dec 16, 2023

Hi,

Can you give us any more details on what you need to achieve?

If you're looking for a way to modify the state machine's transitions at runtime based on external changes, you could look at guard conditions with PermitIf. You could also look at dynamic transitions, which select a destination state based on a delegate and are configured with PermitDynamic – this is an area that could do with better documentation, but the unit tests should give you an idea of how these work.

@Mr-Mohammad
Copy link
Author

I want to design the process first with Json and then let Stateless execute it

@gius
Copy link

gius commented Apr 8, 2024

Hi, do you have any update on this topic? It would be great to be able to (de)serialize a state machine from JSON/XML.

I can imagine dynamically calling the fluent functions to build a state machine based on some template, but feels like a hack to me 🤷

@HenningNT
Copy link
Contributor

Just to be clear, are we talking about storing some object state to database, and then reading in the object into the same state?
The state machine itself is stateless, so it supports de/serializing an object state, please see the JsonExample.

Are we talking about reading in a file that defines the state machine, the guards and actions?
I don't think Stateless will ever support that, unless someone decides they really want that feature, and builds it themselves.

@mclift
Copy link
Member

mclift commented May 21, 2024

I agree with @HenningNT that this isn't likely to be something Stateless would support as a built-in feature and may be better suited to a separate project. All of the state machines I've come across in my work have custom logic (e.g. PermitIf, PermitDynamic, etc.) with dependencies on the application's internals. It shouldn't be too difficult to write a parser to build very simple state machines from Mermaid, DOT graph or some other structured text format, but I don't see a path to building a parser that could include conditionals, dynamic transitions, entry behaviours, or any other custom logic without significant development effort.

All that said, there's a really interesting project idea there and I'd love to see what people would come up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants