Remove SmtpClient and make transport immutable

in Transport methods. Also make proper use of
connection pools.
This commit is contained in:
Alexis Mousset
2020-05-01 20:51:07 +02:00
parent dfbe6e9ba2
commit 0604030b91
20 changed files with 507 additions and 713 deletions

View File

@@ -1,12 +1,8 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use lettre::{
transport::smtp::ConnectionReuseParameters, ClientSecurity, Message, SmtpClient, Transport,
};
use lettre::{Message, SmtpTransport, Transport};
fn bench_simple_send(c: &mut Criterion) {
let mut sender = SmtpClient::new("127.0.0.1:2525", ClientSecurity::None)
.unwrap()
.transport();
let sender = SmtpTransport::new("127.0.0.1").port(2525);
c.bench_function("send email", move |b| {
b.iter(|| {
@@ -24,10 +20,7 @@ fn bench_simple_send(c: &mut Criterion) {
}
fn bench_reuse_send(c: &mut Criterion) {
let mut sender = SmtpClient::new("127.0.0.1:2525", ClientSecurity::None)
.unwrap()
.connection_reuse(ConnectionReuseParameters::ReuseUnlimited)
.transport();
let sender = SmtpTransport::new("127.0.0.1").port(2525);
c.bench_function("send email with connection reuse", move |b| {
b.iter(|| {
let email = Message::builder()