Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 44 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["CryShana <cryshana@cryshana.me>"]
edition = "2018"

[dependencies]
ctrlc = "3.1.9"
mio = "0.8.0"
ctrlc = "3.4.1"
mio = "0.8.9"

[features]
default = ["mio/os-poll", "mio/net"]
2 changes: 0 additions & 2 deletions src/balancer/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ impl TcpClient {
if self.is_connected {
let str = self.target_stream.as_ref().unwrap();
str.shutdown(Shutdown::Both).unwrap_or(());
drop(str);

self.last_connection_loss = Instant::now();
}
Expand All @@ -244,7 +243,6 @@ impl TcpClient {
if self.is_client_connected {
let str = &self.stream;
str.shutdown(Shutdown::Both).unwrap_or(());
drop(str);

self.is_client_connected = false;

Expand Down
12 changes: 8 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod balancer;
use balancer::Poller;
use balancer::RoundRobin;
use balancer::{HostManager, LoadBalancer};

fn main() -> Result<()> {
// PARSE HOSTS
let host_manager = HostManager::new("hosts");
Expand All @@ -19,10 +20,13 @@ fn main() -> Result<()> {
let mut poller = Poller::new(balancer);

// PARSE PORT
let port = get_port().unwrap_or_else(|| {
println!("Invalid listening port provided!");
exit(1);
});
let port = match get_port() {
Some(p) => p,
None => {
println!("Invalid listening port provided, use default 4554");
4554
}
};

// START
poller.start_listening(port).unwrap_or_else(|e| {
Expand Down