entone
StatesLanguage
Declaratively design state machines that compile to Elixir based :gen_statem processes with the States Language JSON specification.
About
States Language is the JSON specification behind AWS Step Functions, a powerful way to coordinate many disparate services into a cohesive “serverless” system. This library uses the same JSON specification and compiles to Elixir based :gen_statem processes.
Why
The initial idea for the Elixir implementation came about while working on an IVR system and we wanted a way to describe “call flows” in a declarative manner. Ideally building a system on top to allow for solution engineers to visually build call flows for a client, without writing any code.
After researching the space a bit, we landed on the States Language spec and decided it was a great fit for describing state machines. With the power of Elixir macros in-hand, this library was born.
I’ve been working on this for a few months now and have found it to be a super useful way to design state machines. Using JSON as a declarative format has also opened up a lot of opportunities for sharing this structure across projects and UIs. There’s even some mix tasks to quickly output your state machines to Graphviz and DagreD3.
The Hexdocs documentation is pretty robust, but feel free to post any questions you have here.
I hope the community finds this as useful of a tool as we have.
Brought to you by Citybase
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
entone
I’ve updated the docs a bit to be more explicit about how to follow along with the example code.
entone
New Release 0.2.4
Big improvements to the JSONPath support. No breaking changes, but handles more edge cases and deeply nested structures better.
kip
Really enjoying following this project and no doubt I will have use for it. Keep up the good work!
entone
Thank you! I’ve found a ton of uses for it.
IVR call flows
LiveView state manager
API input normalization
Microservice orchestration
It’s great being able to vidualize your state machines, and build editors around them.
For building editors, I’ve found being able to use the JSON Schema along with JSON Schema UI for domain specific customization to be really powerful. With dropdowns for known Resource types and TransitionEvents, it’s easy to let non programmers design their state machines.
dimitarvp
Would you care to make a blog post with some examples? I’m considering something like this for months but still can’t quite put my finger on it.
entone
I’ll have a repo of a LiveView example up shortly.
I could probably put something together for an editor as well, but that’s a little more involved, so may take some time.
What would you like to see an example of?
dimitarvp
I’d mostly be happy to see a flow of some sort, where you can’t get to an invalid state if the previous state invariants aren’t satisfied. Doesn’t have to be complex.
I struggle with a complex DB structure in my work where too much objects in the DB can be left in an inconsistent state and something that relies on them down the line can easily break, so I am wondering if a state machine can be a frictionless solution to that.
entone
Here’s an example repo that uses LiveView along with StatesLanguage to define a multi-step form.
https://github.com/entone/states_language_live_view
In the README.md I’ve linked to a few files that I’ve commented on, hopefully it gives you a good idea of how to utilize the library.
This example does have a state that can only be reached given certain criteria.
LostKobrakai
This sounds quite interesting. I‘ve been looking at xstate in js a few weeks ago, which seems to be similar to this library.
entone
It’s similar in that it uses a declarative text format to define your states and transitions. However Javascript doesn’t have gen_statem
And although it abstracts some of the complexities away from utilizing gen_statem, you still have complete access to all the functionality if need be.