refactor
This commit is contained in:
parent
d750f87331
commit
4d590f328f
8 changed files with 39 additions and 33 deletions
|
|
@ -19,8 +19,8 @@ pub use upstream_opts::UpstreamOption;
|
|||
|
||||
// Server name (hostname or ip address) and path name representation in backends
|
||||
// For searching hashmap or key list by exact or longest-prefix matching
|
||||
pub type ServerNameExp = Vec<u8>; // lowercase ascii bytes
|
||||
pub type PathNameExp = Vec<u8>; // lowercase ascii bytes
|
||||
pub type ServerNameBytesExp = Vec<u8>; // lowercase ascii bytes
|
||||
pub type PathNameBytesExp = Vec<u8>; // lowercase ascii bytes
|
||||
|
||||
/// Struct serving information to route incoming connections, like server name to be handled and tls certs/keys settings.
|
||||
pub struct Backend {
|
||||
|
|
@ -111,8 +111,8 @@ impl Backend {
|
|||
|
||||
/// HashMap and some meta information for multiple Backend structs.
|
||||
pub struct Backends {
|
||||
pub apps: HashMap<ServerNameExp, Backend>, // hyper::uriで抜いたhostで引っ掛ける
|
||||
pub default_server_name_bytes: Option<ServerNameExp>, // for plaintext http
|
||||
pub apps: HashMap<ServerNameBytesExp, Backend>, // hyper::uriで抜いたhostで引っ掛ける
|
||||
pub default_server_name_bytes: Option<ServerNameBytesExp>, // for plaintext http
|
||||
}
|
||||
|
||||
impl Backends {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use super::{PathNameExp, UpstreamOption};
|
||||
use super::{PathNameBytesExp, UpstreamOption};
|
||||
use crate::log::*;
|
||||
use rand::Rng;
|
||||
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
|
||||
|
|
@ -12,7 +12,7 @@ use std::{
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReverseProxy {
|
||||
pub upstream: HashMap<PathNameExp, UpstreamGroup>, // TODO: HashMapでいいのかは疑問。max_by_keyでlongest prefix matchしてるのも無駄っぽいが。。。
|
||||
pub upstream: HashMap<PathNameBytesExp, UpstreamGroup>, // TODO: HashMapでいいのかは疑問。max_by_keyでlongest prefix matchしてるのも無駄っぽいが。。。
|
||||
}
|
||||
|
||||
impl ReverseProxy {
|
||||
|
|
@ -70,8 +70,8 @@ pub struct Upstream {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct UpstreamGroup {
|
||||
pub upstream: Vec<Upstream>,
|
||||
pub path: PathNameExp,
|
||||
pub replace_path: Option<PathNameExp>,
|
||||
pub path: PathNameBytesExp,
|
||||
pub replace_path: Option<PathNameBytesExp>,
|
||||
pub lb: LoadBalance,
|
||||
pub cnt: UpstreamCount, // counter for load balancing
|
||||
pub opts: HashSet<UpstreamOption>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue