Skip to content
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

Load balancer #425

Open
wants to merge 64 commits into
base: client-transport-improvements
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
749eded
Prototype version of a query router.
Philip-NLnetLabs Jul 12, 2024
a62225c
Clippy
Philip-NLnetLabs Jul 12, 2024
9772ae0
Features for query-routing.
Philip-NLnetLabs Jul 12, 2024
af1ee53
Remove MyService
Philip-NLnetLabs Jul 12, 2024
0e6d67d
Duplicate mock_instant
Philip-NLnetLabs Jul 12, 2024
27689d2
QnameRouter instead of QueryRouter.
Philip-NLnetLabs Jul 22, 2024
7243cde
SrService becomes SingleService
Philip-NLnetLabs Jul 22, 2024
65095d3
Cargo fmt
Philip-NLnetLabs Jul 23, 2024
67fe2f5
Changes for service-layering
Philip-NLnetLabs Jul 26, 2024
c3fae7a
Adapt to changes in net::client.
Philip-NLnetLabs Aug 29, 2024
1e791a8
Adapts to changes in Service.
Philip-NLnetLabs Sep 2, 2024
0460739
Changes for proxy.
Philip-NLnetLabs Sep 2, 2024
9cab8db
Fmt
Philip-NLnetLabs Sep 2, 2024
2b7e949
Docs
Philip-NLnetLabs Sep 3, 2024
1e77887
Fix example.
Philip-NLnetLabs Sep 5, 2024
2731da8
Docs and cleanup
Philip-NLnetLabs Sep 5, 2024
21c9304
Cleanup use.
Philip-NLnetLabs Sep 5, 2024
fb2f7ec
Document RequestNG
Philip-NLnetLabs Sep 5, 2024
2c779d4
Remove some dead code.
Philip-NLnetLabs Sep 5, 2024
c2bac03
Improvements by Ximon
Philip-NLnetLabs Oct 10, 2024
58b3cb8
WIP
Philip-NLnetLabs Sep 11, 2024
1375b27
WIP
Philip-NLnetLabs Sep 11, 2024
7ce5ff5
wip
Philip-NLnetLabs Sep 16, 2024
398d954
wip
Philip-NLnetLabs Sep 16, 2024
3b5d62a
wip
Philip-NLnetLabs Sep 17, 2024
ab04564
wip
Philip-NLnetLabs Sep 18, 2024
0a29c52
wip
Philip-NLnetLabs Sep 30, 2024
aa677cf
Use Arc for queue length.
Philip-NLnetLabs Oct 3, 2024
f696269
Docs and examples
Philip-NLnetLabs Oct 9, 2024
9d4ae49
Docs
Philip-NLnetLabs Oct 11, 2024
df74b3d
Improved example.
Philip-NLnetLabs Oct 11, 2024
27f213c
Fmt
Philip-NLnetLabs Oct 11, 2024
c2fd2f4
Add Debug
Philip-NLnetLabs Oct 11, 2024
64919fb
Remove unwraps.
Philip-NLnetLabs Oct 14, 2024
4b147a6
Remove unwraps
Philip-NLnetLabs Oct 14, 2024
784b538
Remove unwraps
Philip-NLnetLabs Oct 14, 2024
1c98dec
Merge branch 'main' into qname-router
Philip-NLnetLabs Oct 14, 2024
25d796e
Merge branch 'main' into qname-router
Philip-NLnetLabs Oct 14, 2024
26df1a7
Avoid futures
Philip-NLnetLabs Oct 14, 2024
d71c766
Remove Unpin bounds
Philip-NLnetLabs Oct 14, 2024
6420956
Switch to ServiceError, include EDE to report error.
Philip-NLnetLabs Oct 15, 2024
5094638
Remove unwraps
Philip-NLnetLabs Oct 15, 2024
e371c28
Remove unwraps
Philip-NLnetLabs Oct 15, 2024
0b3bc88
Merge branch 'main' into qname-router
Philip-NLnetLabs Oct 15, 2024
6df7ace
Clippy
Philip-NLnetLabs Oct 15, 2024
794eeec
Merge branch 'qname-router' into load-balancer
Philip-NLnetLabs Oct 16, 2024
304bf41
Small fix
Philip-NLnetLabs Oct 16, 2024
d513f78
Add tracing and more dnsi query examples
Philip-NLnetLabs Oct 18, 2024
9568c0a
Some comments from @bal-e and @tertsdiepraam.
Philip-NLnetLabs Oct 28, 2024
1729ff3
Small fix.
Philip-NLnetLabs Oct 28, 2024
b159484
Clippy
Philip-NLnetLabs Oct 28, 2024
20558da
Move boilerplate out of the way
Philip-NLnetLabs Oct 28, 2024
165339f
Merge branch 'qname-router' into load-balancer
Philip-NLnetLabs Oct 28, 2024
85506e9
Merge branch 'main' into load-balancer
Philip-NLnetLabs Oct 28, 2024
ca9e458
Merge branch 'client-transport-improvements' into load-balancer
Philip-NLnetLabs Oct 28, 2024
e926198
Remove debug output
Philip-NLnetLabs Oct 28, 2024
7efde2e
Clippy
Philip-NLnetLabs Oct 28, 2024
331e833
Fmt
Philip-NLnetLabs Oct 28, 2024
1580844
Merge branch 'client-transport-improvements' into load-balancer
Philip-NLnetLabs Oct 29, 2024
d8420ba
Merge branch 'client-transport-improvements' into load-balancer
Philip-NLnetLabs Oct 29, 2024
ba1efb0
Review feedback.
Philip-NLnetLabs Nov 13, 2024
c772cb8
Clippy.
Philip-NLnetLabs Nov 13, 2024
5591175
Allow value zero for max_burst.
Philip-NLnetLabs Nov 13, 2024
82fffc5
Some more review changes
Philip-NLnetLabs Nov 13, 2024
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ required-features = ["std", "rand"]

[[example]]
name = "client-transports"
required-features = ["net", "unstable-client-transport"]
required-features = ["net", "unstable-client-transport", "tokio-rustls"]

[[example]]
name = "server-transports"
Expand Down
62 changes: 44 additions & 18 deletions examples/client-transports.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
/// Using the `domain::net::client` module for sending a query.
//! Using the `domain::net::client` module for sending a query.
use domain::base::{MessageBuilder, Name, Rtype};
use domain::net::client::protocol::{TcpConnect, TlsConnect, UdpConnect};
use domain::net::client::request::{
RequestMessage, RequestMessageMulti, SendRequest,
};
use domain::net::client::{
cache, dgram, dgram_stream, load_balancer, multi_stream, redundant,
stream,
};
use std::net::{IpAddr, SocketAddr};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use std::vec::Vec;

use domain::base::MessageBuilder;
use domain::base::Name;
use domain::base::Rtype;
use domain::net::client::cache;
use domain::net::client::dgram;
use domain::net::client::dgram_stream;
use domain::net::client::multi_stream;
use domain::net::client::protocol::{TcpConnect, TlsConnect, UdpConnect};
use domain::net::client::redundant;
use domain::net::client::request::{
RequestMessage, RequestMessageMulti, SendRequest,
};
use domain::net::client::stream;

#[cfg(feature = "tsig")]
use domain::net::client::request::SendRequestMulti;
#[cfg(feature = "tsig")]
Expand Down Expand Up @@ -205,9 +200,9 @@ async fn main() {
});

// Add the previously created transports.
redun.add(Box::new(udptcp_conn)).await.unwrap();
redun.add(Box::new(tcp_conn)).await.unwrap();
redun.add(Box::new(tls_conn)).await.unwrap();
redun.add(Box::new(udptcp_conn.clone())).await.unwrap();
redun.add(Box::new(tcp_conn.clone())).await.unwrap();
redun.add(Box::new(tls_conn.clone())).await.unwrap();

// Start a few queries.
for i in 1..10 {
Expand All @@ -220,6 +215,37 @@ async fn main() {

drop(redun);

// Create a transport connection for load balanced connections.
let (lb, transp) = load_balancer::Connection::new();

// Start the run function on a separate task.
let run_fut = transp.run();
tokio::spawn(async move {
run_fut.await;
println!("load_balancer run terminated");
});

// Add the previously created transports.
let mut conn_conf = load_balancer::ConnConfig::new();
conn_conf.set_max_burst(Some(10));
conn_conf.set_burst_interval(Duration::from_secs(10));
lb.add("UDP+TCP", &conn_conf, Box::new(udptcp_conn))
.await
.unwrap();
lb.add("TCP", &conn_conf, Box::new(tcp_conn)).await.unwrap();
lb.add("TLS", &conn_conf, Box::new(tls_conn)).await.unwrap();

// Start a few queries.
for i in 1..10 {
let mut request = lb.send_request(req.clone());
let reply = request.get_response().await;
if i == 2 {
println!("load_balancer connection reply: {reply:?}");
}
}

drop(lb);

// Create a new datagram transport connection. Pass the destination address
// and port as parameter. This transport does not retry over TCP if the
// reply is truncated. This transport does not have a separate run
Expand Down
Loading