Comments (8)
Hi gftea, is this still available to implement? If so, were you thinking an additional function within OpenConnectionArguments
such as from_uri(uri: &str) -> Self
or changing the new
function to only accepting a uri str? Additionally, given 2nd point of the design philosophy, are you against using something like rust-url
(crate is url
) to help with the implementation?
from amqprs.
Hi,
Yes, it is available. I have not yet started working on this. Would you like to work on this?
Because not all arguments in OpenConnectionArguments
can be expressed in URI spec, such as connection_name
and heartbeat
, etc, I think we need to consider URI as a combined aguments as part of OpenConnectionArguments
-
To distinguish URI argument and non URI arguments, we may need to have
new
API like below
pub fn new(host: &str, port: &str, username: &str, password: &str) -> Self
-
change
uri
method's implementation to accept URI spec, instead of supporting only ip_addr:port -
as your suggestion, support something like
from_uri(uri: &str) -> Self
by implementing trait From or TryFrom, but because user may give incorrect URI, so I think we should implementTryFrom
.
The client library only deal with amqp/amqps, does not need generic URL handling, so I think prefer to impelemnt our own parsing, and it should not be too difficult to implement.
from amqprs.
I am a bit naive at first thinking, it looks dealing with URL characters are not a trival task. maybe, as you suggest, we can use rust-url crate
from amqprs.
Hi @gftea, after spending some time on it, I agree its not super trivial. I do have an implementation that correctly parses all of the edge cases listed in the amqp uri spec however, the implementation does not url decode nor am I confident that it will successfully fail if given completely wrong uri's or even more edge cases pertaining to things like query parameters, which I believe are used to control things like the heartbeat.
I do have question about the uri()
function in general. What is it's purpose? Additionally, the uri
field in struct OpenConnectionArguments
currently only pertains to the host and port where the URI spec (RFC 3986) can be used to (almost if not completely) define the values in struct OpenConnectionArguments
. Like the new
function arguments you mentioned before, shouldn't the struct also change to be as verbose as possible and contain a separate host
and port
field and we can keep the uri
field to store the user provided uri
str. If the point of uri()
is to change all fields in the struct to conform to the URI spec, why support this when the user can simply call from_uri
or new
and receive the same result but as a new object? Is the cost of allocating a new OpenConnectionArguments
too expensive considering that users aren't likely to open hundreds to hundreds of thousands OpenConnectionArguments
in any single producer/consumer?
TLDR;
- I have an implementation, but I think its too flawed to handle URIs that are "too incorrect", so I will switch to the
rust-url
crate. There is also theuriparse
crate, which seems to be much less mature thanrust-url
but is ~22% lighter in total package size. uri()
function changes theOpenConnectionArguments
object it is called on in such a significant way that it seems viable to rely on afrom_uri(uri: &str)
or thenew(...args)
function.
from amqprs.
Hi,
You have a good point about uri()
, I agree we should deprecate it, and update the OpenConnectionArguments
to have separate fields for host
and port
. Also we need to add new chainable APIs, host()
and port()
.
I take a quick look both rust-url
and uriparse
, I would prefer rust-url
which is more reliable, good maintainence, and has been used in servo
browser engine also.
I would prefer to consider support of URL spec as optional feature, disabled by default. User can choose to enable.
from amqprs.
Hi gftea, I will continue working on the feature with these guidelines! Thank you for your additional clarification.
from amqprs.
Hi @gftea,
I have two different implementations ready for review. The first implementation uses the crate url
(aka rust-url). I found that this crate is specific to the URL Standard, and NOT the URI Standard outlined in RFC3986. The Rabbit MQ very closely adheres to RFC3986 (based on its many references to the document) and as a result, the rust-url
implementation fails to parse some urls that are said to be correct on the Rabbit MQ uri spec. I created a second implementation using uriparse
to test its behavior, it successfully handles the cases mentioned prior.
The cases where the rust-url fails I found to be mostly from the result of the uri having a zero-length host, which is reasonable to assume would be incorrect, however the RabbitMQ uri spec states it is correct.
Which implementation would you prefer?
from amqprs.
from amqprs.
Related Issues (20)
- FieldTable does not accept integer type HOT 3
- Implementing Prefetch for a given Queue using AsyncConsumer HOT 2
- TLS connection error: connection reset by peer HOT 6
- provide a default TLS configuration using system default root HOT 5
- Not able to run tests on Mac M1 HOT 5
- Consumers crash if they panic HOT 12
- feat: consumer APIs improvements HOT 11
- make channel clonable as connection
- improvement: amqp_serde design and APIs
- Error running the publisher subsriber example. HOT 4
- Consumer immediately gets closed HOT 2
- BasicProperties: expose delivery mode (persistent vs. transient) as a boolean or enum HOT 3
- "Alternative default: queue declaration arguments HOT 1
- BasicPublishArguments: deprecate the immediate field HOT 2
- BasicConsumeArguments: rename no_ack since it is confusing HOT 3
- Address (most) clippy warnings HOT 3
- ConsumerMessage.delivery and .basic_properties should not be options HOT 2
- ExchangeDeclareArguments: exchange type is inherently an enum HOT 3
- FieldTable needs a convenience method for instantiation from a map HOT 4
- Best practices for opening channel, and prevent it from being dropped. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amqprs.