Coder Social home page Coder Social logo

Move to async/.await? about vk-bot HOT 5 OPEN

u32i64 avatar u32i64 commented on August 19, 2024
Move to async/.await?

from vk-bot.

Comments (5)

awaitlink avatar awaitlink commented on August 19, 2024

(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:

  • Initially, rvk was asynchronous (long before async/.await).
  • Then I changed it to be synchronous in v0.2.0 for some reason that I'm not entirely sure about now 😅.
  • After some time I created vk-bot, and decided to go for synchronous as well (async/.await was also not a thing in Rust yet).

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 😉.

  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).

from vk-bot.

prostomarkeloff avatar prostomarkeloff commented on August 19, 2024

The first and second parts are ready I think 😄

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 ...?

from vk-bot.

awaitlink avatar awaitlink commented on August 19, 2024

Ok, so awaitlink/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.

from vk-bot.

prostomarkeloff avatar prostomarkeloff commented on August 19, 2024

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

from vk-bot.

prostomarkeloff avatar prostomarkeloff commented on August 19, 2024

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 😄

from vk-bot.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.