Skip to content

Commit

Permalink
use if let when able
Browse files Browse the repository at this point in the history
Co-authored-by: Bruce Guenter <bruce.guenter@datadoghq.com>
  • Loading branch information
DominicBurkart and bruceg committed May 30, 2023
1 parent 0d9fbcd commit 7975b08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/vector-common/src/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ impl SourceShutdownCoordinator {
) -> impl Future<Output = bool> {
async move {
let fut = shutdown_complete_tripwire.then(tripwire_handler);
if deadline.is_some() {
if let Some(deadline) = deadline {
// Call `shutdown_force_trigger.disable()` on drop.
let shutdown_force_trigger = DisabledTrigger::new(shutdown_force_trigger);
if timeout_at(deadline.unwrap(), fut).await.is_ok() {
if timeout_at(deadline, fut).await.is_ok() {
shutdown_force_trigger.into_inner().disable();
true
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/topology/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ impl RunningTopology {
.graceful_shutdown_duration
.map(|grace_period| Instant::now() + grace_period);

let timeout = if deadline.is_some() {
let timeout = if let Some(deadline) = deadline {
// If we reach the deadline, this future will print out which components
// won't gracefully shutdown since we will start to forcefully shutdown
// the sources.
let mut check_handles2 = check_handles.clone();
Box::pin(async move {
sleep_until(deadline.unwrap()).await;
sleep_until(deadline).await;
// Remove all tasks that have shutdown.
check_handles2.retain(|_key, handles| {
retain(handles, |handle| handle.peek().is_none());
Expand Down

0 comments on commit 7975b08

Please sign in to comment.