Skip to content

Commit

Permalink
refactor(examples): use non deprecated methods
Browse files Browse the repository at this point in the history
Signed-off-by: Florentin Dubois <florentin.dubois@clever-cloud.com>
  • Loading branch information
FlorentinDUBOIS committed Jul 30, 2024
1 parent f955646 commit c217d17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async fn main() -> Result<(), pulsar::Error> {
loop {
println!("will send");
let receipt_rx = producer
.send(TestData {
.send_non_blocking(TestData {
data: "data".to_string(),
})
.await
Expand Down
2 changes: 1 addition & 1 deletion examples/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn main() -> Result<(), pulsar::Error> {
let mut counter = 0usize;
loop {
producer
.send(TestData {
.send_non_blocking(TestData {
data: "data".to_string(),
})
.await?
Expand Down
2 changes: 1 addition & 1 deletion examples/round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async fn main() -> Result<(), pulsar::Error> {
let mut counter = 0usize;
loop {
producer
.send(TestData {
.send_non_blocking(TestData {
data: "data".to_string(),
})
.await
Expand Down
12 changes: 4 additions & 8 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,12 @@ impl<Exe: Executor> Connection<Exe> {
if tls {
let stream = tokio::net::TcpStream::connect(&address).await?;
let mut root_store = rustls::RootCertStore::empty();

root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
for certificate in certificate_chain {
root_store.add(certificate.clone())?;
}

for trust_anchor in webpki_roots::TLS_SERVER_ROOTS {
root_store.roots.push(trust_anchor.clone());
}

let config = rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth();
Expand Down Expand Up @@ -1079,14 +1077,12 @@ impl<Exe: Executor> Connection<Exe> {
if tls {
let stream = async_std::net::TcpStream::connect(&address).await?;
let mut root_store = rustls::RootCertStore::empty();

root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
for certificate in certificate_chain {
root_store.add(certificate.clone())?;
}

for trust_anchor in webpki_roots::TLS_SERVER_ROOTS {
root_store.roots.push(trust_anchor.clone());
}

let config = rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth();
Expand Down

0 comments on commit c217d17

Please sign in to comment.