Skip to content

Commit

Permalink
fix: Adjust the frequency of push notifications for positions check
Browse files Browse the repository at this point in the history
Improve documentation and adjust how often we run the check to minimise the
changes of user receiving 2 notifications (it can still happen, but it is
around 3% now (overlapping the time a bit to ensure we don't out miss sending out
the notification).
  • Loading branch information
klochowicz committed Sep 20, 2023
1 parent c694d36 commit 8f887fc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions coordinator/src/bin/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ const EXPIRED_POSITION_SYNC_INTERVAL: Duration = Duration::from_secs(5 * 60);
const CLOSED_POSITION_SYNC_INTERVAL: Duration = Duration::from_secs(30);
const UNREALIZED_PNL_SYNC_INTERVAL: Duration = Duration::from_secs(10 * 60);
const CONNECTION_CHECK_INTERVAL: Duration = Duration::from_secs(30);
const EXPIRED_POSITION_NOTIFICATION_INTERVAL: Duration = Duration::from_secs(30 * 60);
/// How often to check for expiring/expired positions to send push notifications for.
/// This should be configured in conjunction with the time windows of
/// expiring/expired notifications, ideally a bit less than the time window
/// (e.g. 58min for a 1h time window).
const POSITION_PUSH_NOTIFICATION_INTERVAL: Duration = Duration::from_secs(58 * 60);

const NODE_ALIAS: &str = "10101.finance";

Expand Down Expand Up @@ -277,6 +281,7 @@ async fn main() -> Result<()> {
let pool = pool.clone();
async move {
loop {
tracing::debug!("Running expiring/expired position push notification task");
match pool.get() {
Ok(mut conn) => {
if let Err(e) =
Expand All @@ -290,7 +295,7 @@ async fn main() -> Result<()> {
}
}

tokio::time::sleep(EXPIRED_POSITION_NOTIFICATION_INTERVAL).await;
tokio::time::sleep(POSITION_PUSH_NOTIFICATION_INTERVAL).await;
}
}
});
Expand Down

0 comments on commit 8f887fc

Please sign in to comment.