awaitlink / vk-bot

:package: Crate for building chat bots for VK communities (uses Callback API)
https://crates.io/crates/vk-bot
MIT License
5 stars 2 forks source link

Move to async/.await? #10

Open prostomarkeloff opened 4 years ago

prostomarkeloff commented 4 years ago

No way of getting moved to async/.await and (maybe) supporting longpoll? I'd love it and can help with it.

awaitlink commented 4 years ago

(maybe) supporting longpoll

In my opinion this has little relation to async/.await, so please open a separate issue for supporting long polling.


getting moved to async/.await

I am certainly not against it!

The reason vk-bot is currently synchronous is as follows:

So for making it async/.await, the following needs to be done, I think (do correct me if I'm wrong somewhere):

  1. Transition rvk to use async/.await. While this is likely not strictly required I guess, it'd certainly be nice for essentially the "backend" of vk-bot to be asynchronous as well in the first place.

    This should be relatively straightforward, most actual changes would be in api.rs:

    • Choose a library to use. I think surf is a great option right now?
    • APIClient should store some sort of a Client if such thing is needed/exists in the chosen library.
    • call_method should be made async and use that library to call API methods.
  2. Release a new (major) version of rvk.

  3. Close Dependabot's PR attempt to migrate vk-bot to that version as it should fail, if I understand correctly.

  4. Change vk-bot to use the new version of rvk.

    A little bit more involved than step 1: while it should be straightforward theoretically, I'm not exactly sure how well/simply that'd work with Rocket. Anything mentioning API calls would probably need to be changed initially, and then rustc is your best friend, as always :wink:.

  5. Release a new (major) version of vk-bot.

I'd love it and can help with it.

Awesome! Then I think you can start by opening a PR on rvk with the needed changes (also feel free to open a draft PR right away if you want).

prostomarkeloff commented 4 years ago

The first and second parts are ready I think :smile:

But I'm a bit unsure about rocket because it supports async/.await only in git's version. What's about moving to any other framework or ...?

awaitlink commented 4 years ago

Ok, so u32i64/rvk#9 is merged now. As far as I understand, you'd like to change some other things in rvk as well.

So we could either:

  1. Release new rvk version now and proceed with other changes to get async/.await support first, and then do the other improvements after that is done.
  2. Or I will wait for your changes, and then we'll proceed on async/.await.

Personally, I think 1 is a better option. Do you have any preference?

But I'm a bit unsure about rocket because it supports async/.await only in git's version. What's about moving to any other framework or ...?

Hmm. Ideally I'd like to not change that... but I see that Rocket's async is still in progress, yes. The good news is that there are just a handful of HTTP requests that need to be handled, so switching shouldn't be that complex.

Do you have any preferred alternatives in mind? From my quick look warp looks good enough for vk-bot's purposes.

prostomarkeloff commented 4 years ago

Yeah, I think warp is ok for this. I choose the second option. I'll write here when rvk is ready.

prostomarkeloff commented 4 years ago

Ok, I think rvk is ready! I'll add async/.await support for vk-bot in next PR. Also I want to extend the features of vk-bot and release async/.await with them :smile: