Skip to content

Add the name resolver API #2285

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

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

arjan-bal
Copy link
Contributor

No description provided.

@arjan-bal
Copy link
Contributor Author

@dfawley @LucioFranco

pub fn new(mut config: BackoffConfig) -> Self {
// Adjust params to get them in valid ranges.
// 0 <= base_dealy <= max_delay
config.base_delay = config.base_delay.min(config.max_delay);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't ensure it isn't negative (max(0)) and doesn't validate max_delay at all.

Also, maybe new should return a Result instead and fail if things are out of range, rather than silently "fixing" the errors.

Comment on lines +76 to +77
let mut next_delay = self.next_delay_secs.lock().unwrap();
*next_delay = self.config.base_delay.as_secs_f64();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut next_delay = self.next_delay_secs.lock().unwrap();
*next_delay = self.config.base_delay.as_secs_f64();
self.next_delay_secs.set(self.config.base_delay.as_secs_f64());


/// The delay for the next retry, without the random jitter. Store as f64
/// to avoid rounding errors.
next_delay_secs: Mutex<f64>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need a mutex? It seems like we should generally only be accessing these serially.

/// to prevent excessive re-resolution.
static MIN_RESOLUTION_INTERVAL_MS: AtomicU64 = AtomicU64::new(30_000); // 30 seconds

pub fn get_resolving_timeout() -> Duration {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions should presumably have the comments above, since they are public but the variables are not. But the module is not public, so it's not too important for now.

Comment on lines +121 to +123
let (resolve_now_tx, mut resolve_now_rx) = tokio::sync::mpsc::unbounded_channel::<()>();
let (update_error_tx, update_error_rx) =
tokio::sync::mpsc::unbounded_channel::<Result<(), String>>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// Asks the resolver to obtain an updated resolver result, if
/// applicable.
///
/// This is useful for pull-based implementations to decide when to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have standardized on poll and watch for the two resolver types.

Comment on lines +178 to +179
/// Called serially by the channel to do work after the work scheduler's
/// schedule_work method is called.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to do work" -> "to allow access to ChannelController" or something?

Comment on lines +220 to +222
/// returns an empty endpoint list but a valid service config may set
/// to this to something like "no DNS entries found for <name>".
pub resolution_note: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some requirement for using this? Like should it only be set if endpoints is empty? I.e. should we delete this and use an Err() from endpoints instead?

pub resolution_note: Option<String>,
}

impl Default for ResolverUpdate {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be derived? Or no because of Result? If the latter, is there some way to partially derive?

/// Creates and returns an instance of a DNSResolver, optionally
/// configured by the ResolverOptions struct. This method may return an
/// error if it fails to create the DNSResolver.
fn get_dns_resolver(&self, opts: ResolverOptions) -> Result<Box<dyn DnsResolver>, String>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it complicate things that this is fallible? I think we could make it infallible if we wanted?

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

Successfully merging this pull request may close these issues.

2 participants