-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(BOUN-1156): Integration of Discovery Library #3
feat(BOUN-1156): Integration of Discovery Library #3
Conversation
acd7193
to
78af939
Compare
78af939
to
3ca5234
Compare
src/cli.rs
Outdated
|
||
/// Whether to use static URLs or dynamically discovered URLs for routing. | ||
/// For the dynamic routing case, provided argument ic-url: Vec<Url> is used as a seed list of API Nodes. | ||
#[clap(long = "use_dynamic_routing")] |
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.
Change to ic-use-dynamic-routing
or better ic-use-discovery
maybe...
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.
done
src/routing/ic/health_check.rs
Outdated
const SERVICE_NAME: &str = "HealthCheckImpl"; | ||
|
||
#[derive(Debug)] | ||
pub struct HealthCheckImpl { |
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'd call that HealthChecker
or smth like this, I don't understand those -Impl
suffixes :)
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.
done
src/routing/ic/transport.rs
Outdated
.map_err(|err| TransportProviderError::UnableToGetTransport(err.to_string()))?, | ||
); | ||
|
||
Ok(transport as Arc<dyn Transport>) |
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.
as Arc<dyn Transport>
isn't needed here I think
src/tasks.rs
Outdated
S: Send + Sync + Debug + Clone + Snapshot + 'static, | ||
{ | ||
async fn run(&self, token: CancellationToken) -> Result<(), Error> { | ||
self.0.run().await; |
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.
It will get stuck on this await
forever and will not stop when the token is cancelled. You need select!
here.
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 thought about using select!
when implementing it, but it felt unnecessary. self.0.run().await;
is designed to return immediately. So the token cancellation will be awaited right away and will let the stop()
be called after.
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 can put select!
though to make it even more robust
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.
on the other hand, calling self.0.stop()
before this nearly instantself.0.run().await
finishes can be IMO ungraceful, as this is rather start()
actually
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.
if run()
does not block on await then it's ok as-is, I thought it just blocks there.
src/tasks.rs
Outdated
@@ -63,3 +64,18 @@ impl Run for ocsp_stapler::Stapler { | |||
Ok(()) | |||
} | |||
} | |||
|
|||
pub struct TaskRouteProvider<S>(pub Arc<HealthCheckRouteProvider<S>>); |
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.
Btw do we even need a newtype around it? Maybe just implement Run
directly?
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.
not necessary indeed, i thought having the same run()
method would be confusing for the compiler, but it seems not
e82d9b4
to
1cbeb82
Compare
src/routing/mod.rs
Outdated
return Err(anyhow!("Seed list of API Nodes can't be empty")); | ||
} | ||
|
||
let route_provider = { |
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.
Can we maybe move this stuff along with the constants somewhere to the ic
module? To keep setup_router()
shorter and cleaner.
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.
sure, done
src/routing/ic/transport.rs
Outdated
let route_provider = Arc::new( | ||
RoundRobinRouteProvider::new(vec![url.as_str()]) | ||
.map_err(|err| TransportProviderError::UnableToGetTransport(err.to_string()))?, | ||
) as Arc<dyn RouteProvider>; |
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.
Again as Arc<dyn RouteProvider>
isn't needed, Rust is smart enough to figure out :)
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.
clippy is needed here
23d3c84
to
85ee156
Compare
85ee156
to
a784363
Compare
Hey I guess let's merge it, though I made some changes to the router but I guess it should merge w/o conflicts. |
Incorporate
HealthCheckRouteProvider
toic-gateway
for dynamic routing mode.