Skip to content

Commit b9650b8

Browse files
committed
notes
Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
1 parent 2f4edf5 commit b9650b8

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

src/generator/tcp.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,10 @@ impl Tcp {
151151
let total_bytes = blk.total_bytes;
152152

153153
tokio::select! {
154-
conn = TcpStream::connect(self.addr), if connection.is_none() => {
155-
match conn {
156-
Ok(client) => {
157-
connection = Some(client);
158-
}
159-
Err(err) => {
160-
trace!("connection to {} failed: {}", self.addr, err);
154+
biased;
161155

162-
let mut error_labels = labels.clone();
163-
error_labels.push(("error".to_string(), err.to_string()));
164-
counter!("connection_failure", 1, &error_labels);
165-
}
166-
}
167-
}
168156
_ = self.throttle.wait_for(total_bytes), if connection.is_some() => {
169-
let mut client = connection.unwrap();
157+
let mut client: TcpStream = connection.unwrap();
170158
let blk = blocks.next().unwrap(); // actually advance through the blocks
171159
match client.write_all(&blk.bytes).await {
172160
Ok(()) => {
@@ -183,6 +171,23 @@ impl Tcp {
183171
}
184172
}
185173
}
174+
conn = TcpStream::connect(self.addr), if connection.is_none() => {
175+
match conn {
176+
Ok(client) => {
177+
connection = Some(client);
178+
}
179+
Err(err) => {
180+
// TODO should sleep on connection failure since we
181+
// generate 77k attempts in capture output in one
182+
// run alone
183+
trace!("connection to {} failed: {}", self.addr, err);
184+
185+
let mut error_labels = labels.clone();
186+
error_labels.push(("error".to_string(), err.to_string()));
187+
counter!("connection_failure", 1, &error_labels);
188+
}
189+
}
190+
}
186191
_ = self.shutdown.recv() => {
187192
info!("shutdown signal received");
188193
return Ok(());

0 commit comments

Comments
 (0)