-
Notifications
You must be signed in to change notification settings - Fork 46
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
chore: remove Endpoint and Protocol types #654
chore: remove Endpoint and Protocol types #654
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure when/whether we need the protocol http
prefix or not?
You'll also need to add a |
Yea the faucet config might be the only one that should omit it:
I think the rest should have the protocol specified (as per your suggested fixes). I was hoping some tests would prove me right / wrong but I haven't checked yet. |
I think there are no tests that actually validate the urls. We should at minimum add tests for the default settings. This does make me wonder - maybe instead of Then our tests for the config files and defauls would pass/fail deserialization. |
This would be my goto approach. I can do that in the next commit. Alternative to that (I prefer the Url type) is to have the protocol prefix in every instance of the String and do this in that socket addr flow: let endpoint = config.endpoint.split_once("://").unwrap_or(("", &config.endpoint)).1; |
Let's go with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impl looks good; just the question of http::Uri
via tonic
or url::Url
. tbh I'm unsure :) Less deps is nice so maybe the former?
33a3b9d
to
5eec3fb
Compare
I implemented the Uri approach in an alternate branch. I didn't push it to this branch because the last part of the impl made me think we should stick with Url instead. Url is a more accurate type for our use case here - we actually use all the values as URLs. Uri's might not have a host/port so for example the conversion to socket address involves options here: let socket_addr = (
config
.endpoint
.host()
.ok_or(anyhow::anyhow!("Config endpoint with no host: {}", config.endpoint))?,
config
.endpoint
.port_u16()
.ok_or(anyhow::anyhow!("Config endpoint with no port: {}", config.endpoint))?,
);
let rpc_listener = TcpListener::bind(socket_addr).await?; We would want to abstract that logic behind a common trait rather than repeat it for every config that has a Uri in it. At that point we are (ironically) creating an abstraction because we introduced Uri which is a less accurate and convenient type than Url for our use case. Url naturally provides the This branch is ready for review again with the Url approach. LMK your thoughts and anything else to change. TY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
Apologies about the back and forth; but I think we landed in a good spot.
Co-authored-by: Mirko <48352201+Mirko-von-Leipzig@users.noreply.github.com>
Closes #651