-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: allow FSMs to specify the next event to send #1723
Conversation
c34d1f8
to
42f0e72
Compare
e70ecb5
to
3845ebd
Compare
76cfcb2
to
7b73b49
Compare
@alecthomas Please review if you get a chance, even though you're not a reviewer because you're the author |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I can't approve my own PR, but you probably can :)
// Each transition also declares the next state(s) to transition to using State | ||
// | ||
//ftl:retry 2 1s | ||
var fsm = ftl.FSM("fsm", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to introduce ftl.FSMNext()
in this PR so we don't establish this pattern at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alecthomas I've added that now. Do you know why the grpc for a call included metadata key value pairs? I can't see it used anywhere, but this seemed like a reasonable use case for it so I piggy backed on it. What do you think?
Isolated commit here: move from fsm.Next() to FSMNext()
} | ||
|
||
//ftl:typealias | ||
type EventB Event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of the type aliases? Unless there's a reason it would probably be simpler and less confusing to use type EventB struct {}
validateAsyncCall("created", "Rosebud"), | ||
validateAsyncCall("paid", "Rosebud"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests is for encryption, can we move these changes to a new test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this test are to make sure we are encrypting the payload in the fsm next event table
ed4048f
to
024bd8f
Compare
024bd8f
to
7915692
Compare
# Conflicts: # backend/controller/dal/fsm.go # backend/controller/dal/fsm_integration_test.go # internal/encryption/integration_test.go
88c2d1b
to
86a7321
Compare
bc89136
to
5f3a3a0
Compare
closes #1664
closes #2334
This is particularly useful when an FSM state itself knows which state it should be in next, for example transitioning a payment to "voided" if an error occurs communicating with an external vendor.
fsm.Next(ctx, event)
to the go runtimeIn another PR we will move away from using
ftl.Next()
to avoid the reference cycle issue.