-
Notifications
You must be signed in to change notification settings - Fork 204
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
Feature Request: Async api for receiving messages #999
Comments
Consider what happens when a bot gets restarted, which can happen due to some server error or if you decided to update the code. In this case, a user should not notice anything, but with the approach you've suggested the dialogue will be removed from memory and lost forever. From the point of a user, it'd look like a bug. It's true that Also, the approach of saving the dialogue state in certain points is error-prone -- we can just forget to do that. On the other hand, the current approach with FSMs does it automatically behind the scenes. |
I think what @HKalbasi is trying to highlight here is that dialogues are usually short lived, so in a lot of cases it does not matter much if we lose it. (the probability to loose it mid dialogue is lower because it's short lived, it can be redone easily for the same reason, etc) |
And it doesn't need to replace the current api, just complement it. For long dialogues or cases that persistence is very important, users can always use the current api. |
I think my biggest concern here is that this requires quite a bit of design & implementation work. Given our capacity I don't think we'll be able to get to it anytime soon. But it does look like with enough work & workarounds, this should be possible to implement. So, maybe one day :) |
A sudden interruption of the control flow can still look like a bug though. If a bot has enough users, this will certainly be noticed at some point. My other concern is having two alternative implementations of the same idea. What usually happens is that users prefer the nicer-looking solution, then (some part of users) stumble upon the limitations of the basic solution, then rewrite the logic to use the more advanced solution. We already have it in the form of REPLs/dispatcher. Having it also for dialogues/ Other than that, I agree with @WaffleLapkin that we don't have the capacity to implement it anytime soon. |
Using async/await instead of manual state machine can dramatically simplify code. For example the
Dialogues management
example in the readme can become something like this:Pros
prompt
function to dosend_message + receive_message
, or extract the loop in the example above asfallible_prompt("Send me a number", |x| x.parse::<u8>())
Cons
The text was updated successfully, but these errors were encountered: