-
Notifications
You must be signed in to change notification settings - Fork 84
feat(BOUN-1168): add dynamic route provider (Discovery Library) #568
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-1168): add dynamic route provider (Discovery Library) #568
Conversation
8b99ff6 to
f831d96
Compare
| } | ||
|
|
||
| pub fn is_valid_domain<S: AsRef<str>>(domain: S) -> bool { | ||
| // TODO |
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 would just use the same as here: https://github.com/dfinity/ic/blob/master/rs/registry/canister/src/mutations/common.rs#L131-L155
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 think reusing the Url library is more concise:
pub fn is_valid_domain<S: AsRef<str>>(domain: S) -> bool {
// Prepend scheme to make it a valid URL
let url_string = format!("http://{}", domain.as_ref());
Url::parse(&url_string).is_ok()
}
| where | ||
| S: RoutingSnapshot + 'static, | ||
| { | ||
| pub fn new(snapshot: S, seeds: Vec<Node>, http_client: Client) -> Self { |
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.
This means that to create an agent with the discovery library, you need to do something like:
let snapshot = LatencyBasedSnapshot::new();
let http_client = Client::builder().build().unwrap();
let route_provider = HealthCheckRouteProvider::new(
snapshot,
vec![Node::new(domain_seed)],
http_client
);
let transport = ReqwestTransport::create_with_client_route(
Arc::clone(&route_provider) as Arc<dyn RouteProvider>,
http_client,
)
.expect("failed to create transport");
let agent = Agent::builder()
.with_transport(transport)
.build()?;
Can't we do something like and just provide defaults:
let agent = Agent::builder()
.with_latency_based_routing()
.build()?;
or
let agent = Agent::builder()
.with_health_based_routing()
.build()?;
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 someone wants not the default, they can then go through the process above and create their own snapshot/route provider, etc.
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.
Eventually this is the direction to go, yes! But i don't want to change the agent during the library migration phase., better in the follow up.
25794d8 to
a990a93
Compare
a990a93 to
bfc28fe
Compare
6ba98ad to
973b377
Compare
39567c9 to
32bc62e
Compare
68a64ea to
55656b4
Compare
d946b18 to
ce03d41
Compare
ce03d41 to
a2d4799
Compare
b7492ff to
e79769f
Compare
cb38300 to
d645367
Compare
d645367 to
38a8b45
Compare
4e8ee0c to
1c93d1c
Compare
f0721eb to
fe39797
Compare
0a5d542 to
ad521f4
Compare
* feat(BOUN-1168): add dynamic route provider (Discovery Library) (#568) --------- Co-authored-by: Nikolay Komarevskiy <90605504+nikolay-komarevskiy@users.noreply.github.com>
Description
API boundary nodes (BNs) have already been introduced into the Internet Computer (IC) landscape. Currently, the
agentdoes not support dynamic discovery of existing API BNs or the dynamic routing of requests to these nodes based on specific strategies, such as latency. This PR enhances theagentby adding functionality for the dynamic routing to API BNs. In a nutshell the newly introduced DynamicRouteProvider is the implementation of the RouteProvider trait.Example usage 1 - ergonomic:
Example usage 2 - fully customized:
How Has This Been Tested?
system-testin theic-repo.NOTE: @adamspofford-dfinity and @lwshang the suggestion to fully remove the
fetch_root_key()was probably wrong. Assystem-testfails without this call. Could You commit a conditionalfetch_root_key()invocation, which would work for bothmainnetandtestnets.Checklist: