Skip to content

Commit

Permalink
Remove unnecessary stub code
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmunns committed Jun 19, 2024
1 parent 713dbdb commit 2a6b846
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions source/river/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ use crate::{
proxy::request_modifiers::RequestModifyMod,
};

use self::{
request_selector::{null_selector, RequestSelector},
response_modifiers::ResponseModifyMod,
};
use self::{request_selector::RequestSelector, response_modifiers::ResponseModifyMod};

pub mod request_modifiers;
pub mod request_selector;
Expand Down Expand Up @@ -55,22 +52,15 @@ pub fn river_proxy_service(
) -> Box<dyn pingora::services::Service> {
// Pick the correctly monomorphized function. This makes the functions all have the
// same signature of `fn(...) -> Box<dyn Service>`.
type ServiceMaker =
fn(ProxyConfig, &Server, RequestSelector) -> Box<dyn pingora::services::Service>;
let (service_maker, selector): (ServiceMaker, RequestSelector) =
match conf.upstream_options.selection {
SelectionKind::RoundRobin => (
RiverProxyService::<RoundRobin>::from_basic_conf,
null_selector,
),
SelectionKind::Random => (RiverProxyService::<Random>::from_basic_conf, null_selector),
SelectionKind::Fnv => (RiverProxyService::<FVNHash>::from_basic_conf, null_selector),
SelectionKind::Ketama => (
RiverProxyService::<KetamaHashing>::from_basic_conf,
null_selector,
),
};
service_maker(conf, server, selector)
type ServiceMaker = fn(ProxyConfig, &Server) -> Box<dyn pingora::services::Service>;

let service_maker: ServiceMaker = match conf.upstream_options.selection {
SelectionKind::RoundRobin => RiverProxyService::<RoundRobin>::from_basic_conf,
SelectionKind::Random => RiverProxyService::<Random>::from_basic_conf,
SelectionKind::Fnv => RiverProxyService::<FVNHash>::from_basic_conf,
SelectionKind::Ketama => RiverProxyService::<KetamaHashing>::from_basic_conf,
};
service_maker(conf, server)
}

impl<BS> RiverProxyService<BS>
Expand All @@ -82,7 +72,6 @@ where
pub fn from_basic_conf(
conf: ProxyConfig,
server: &Server,
selector: RequestSelector,
) -> Box<dyn pingora::services::Service> {
let modifiers = Modifiers::from_conf(&conf.path_control).unwrap();

Expand All @@ -95,7 +84,7 @@ where
Self {
modifiers,
load_balancer: upstreams,
request_selector: selector,
request_selector: conf.upstream_options.selector,
},
&conf.name,
);
Expand Down

0 comments on commit 2a6b846

Please sign in to comment.