Skip to content
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

any plans to rewrite bramqp in async/await? #56

Open
Dmitry-N-Medvedev opened this issue Oct 12, 2017 · 6 comments
Open

any plans to rewrite bramqp in async/await? #56

Dmitry-N-Medvedev opened this issue Oct 12, 2017 · 6 comments

Comments

@Dmitry-N-Medvedev
Copy link

...this would be very handy for modern NodeJS

@bakkerthehacker
Copy link
Owner

bakkerthehacker commented Oct 12, 2017

I dont have any immediate plans to update bramqp to use more modern javascript features, but it is something I have thought about. Updating the callbacks to something more suitable does make sense, but the library does function as is. Another consideration is which version of node is supported. Currently, bramqp works with node all the way back to version 0.10

@Dmitry-N-Medvedev
Copy link
Author

If I am not mistaken, node since v. 7.0.0 does natively support async/await

@bakkerthehacker
Copy link
Owner

bakkerthehacker commented Aug 29, 2019

With the release of many of the important async / await features in node 12, I am happy to refactor bramqp to use promises.

My plan is to have the interface look something like:

handle.server.channel(num)[class][method](), async generator that emits methods from the server

handle.client.channel(num)[class][method](...args), async, returns promise that resolves on server response

@bakkerthehacker
Copy link
Owner

bakkerthehacker commented Jan 22, 2020

Just wanted to give an update. I have built out some async prototypes and looked into a few strategies here.

The branches generator-dev and async-dev contain some of my initial prototyping with various javascript async features. However, in my building, especially when trying to use generators to nicely encapsulate parsing, i ran into limitations in the vanilla js generators.

In addition to vanilla features, node also provides streams. While this interface is a bit different, it seems more suitable for bramqp internals as it contains piping and flow control. My work on converting bramqp to use duplex streams is more complete than the other two branches but it is not entirely finished. It available in the stream-dev branch. While some of the internals may change a bit still, this new tutorial is what I am looking to implement and is a good reference for the new interface. (the 1st has been updated, some of the others still need to be)

With this new interface, each level of amqp is a stream (handle, channel, class, method). Data can be sent to the server by writing to the stream using the appropriate interface. Methods may also be called and will send the data to the stream. These streams also produce data when it is received from the server.

@Dmitry-N-Medvedev
Copy link
Author

just came across this article regarding node streams: https://github.com/nodejs/readable-stream

hope this helps :)

@bakkerthehacker
Copy link
Owner

Thanks for the insight but maybe I don't see the same issues with the stock streams as that author does. The blog post is from 2014 and is mainly raising issue with changing interfaces from streams in node 0.8-0.10. These node versions are quite old so I am fine relying on stock streams3 from node 12 onward rather than adding more to the npm install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants