What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Would it be a nice feature in the state machine to have pre and post (condition) commands?
Would it be a nice feature in the state machine to have pre and post (condition) commands?
Comments
-
What exactly do you mean?
0 -
so state:
waiting for status
transitions toauth declined
0 -
it would be nice if I could execute a command (
send email
) after the condition for that transition is true0 -
as currently commands are executed before conditions
0 -
the "solution" is to add an intermediate state, but the state machine can become bloated
0 -
Agree, and on other hand itβs clearly understandable where item currently is
0 -
and what exactly failed in case
0 -
but in these cases there is no "else"
0 -
as failure is not expected (no external systems involved)
0 -
Other state machine libraries support pre/post events (e.g. the one used Sylius)
0 -
isn't pre/post event just a transition that is not explicit? In theory you can hide email sending into the condition but I would not recommend it
0 -
failure is not expected -> famous last words π
0 -
but in this case I would add about 6 states for sending emails, and the transition woul dbe to
auth suspened email sent
0 -
auth suspend email send fail
0 -
retry auth suspend email
etc0 -
technically it makes sense, but practically it's hard
0 -
You can put it into subprocess to separate some functionality like
email sending
0 -
i think that just moves the complexity to another file?
0 -
so this is what I am going with now:
0 -
sending declined email
is not a good state name, maybeready to send declined email
?0 -
or any other approach?
0 -
In my opinion it should be
waiting for auth status
->auth declined
->order declined email sent
0 -
um, that makes more sense I think π
0 -
@UKGT7RC7P In an early version of the state machine we had something similar to this. The problem is that whenever you run logic, something can fail und you end up somewhere between the states. Thatβs why I think itβs a better practice to run only one command per transition.
0 -
The official solution is to add a state as you described already. We had very big state machines in the past and when you use sub-processes it doesnβt become chaotic.
0 -
that can still be the case now though - commands can fail for any unexpected reason
0 -
Yes and then you end up in the last state before this transition
0 -
and unless you are highly defensive (failure condition, catching all exceptions) and have a failure state for each command
0 -
it's the same as running one or multiple commands
0 -
(and arguably you can "trust" some commands which run within the system)
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random