server: do not keep ownership of all options

* We don't actually need all of the options; instead, move all the
  options to the respective structs and disown them immediately.
This commit is contained in:
Peter Cai 2021-04-05 13:56:44 +08:00
parent ef3657aadb
commit 41f05cacb2

View file

@ -52,18 +52,18 @@ pub struct ServerOptions {
} }
pub struct Server { pub struct Server {
options: ServerOptions,
client: Client, client: Client,
retries: usize,
} }
impl Server { impl Server {
fn new(options: ServerOptions) -> Server { fn new(options: ServerOptions) -> Server {
Server { Server {
client: Client::new( client: Client::new(
options.upstream_urls.clone(), options.upstream_urls,
OverrideResolver::new(options.overrides.clone(), options.override_ttl), OverrideResolver::new(options.overrides, options.override_ttl),
), ),
options, retries: options.retries,
} }
} }
@ -83,7 +83,7 @@ impl Server {
let questions = err_response!(Self::extract_questions(body)); let questions = err_response!(Self::extract_questions(body));
let records = err_response!( let records = err_response!(
self.client self.client
.query_with_retry(questions.clone(), self.options.retries) .query_with_retry(questions.clone(), self.retries)
.await .await
); );
let resp_format = Self::get_response_format(&req); let resp_format = Self::get_response_format(&req);