MCPcopy Create free account
hub / github.com/chatmail/core / location_loop

Function location_loop

src/location.rs:720–757  ·  view source on GitHub ↗
(context: &Context, interrupt_receiver: Receiver<()>)

Source from the content-addressed store, hash-verified

718}
719
720pub(crate) async fn location_loop(context: &Context, interrupt_receiver: Receiver<()>) {
721 loop {
722 let next_event = match maybe_send(context).await {
723 Err(err) => {
724 warn!(context, "location::maybe_send failed: {:#}", err);
725 Some(60) // Retry one minute later.
726 }
727 Ok(next_event) => next_event,
728 };
729
730 let duration = if let Some(next_event) = next_event {
731 Duration::from_secs(next_event)
732 } else {
733 Duration::from_secs(86400)
734 };
735
736 info!(
737 context,
738 "Location loop is waiting for {} or interrupt",
739 duration_to_str(duration)
740 );
741 match timeout(duration, interrupt_receiver.recv()).await {
742 Err(_err) => {
743 info!(context, "Location loop timeout.");
744 }
745 Ok(Err(err)) => {
746 warn!(
747 context,
748 "Interrupt channel closed, location loop exits now: {err:#}."
749 );
750 return;
751 }
752 Ok(Ok(())) => {
753 info!(context, "Location loop received interrupt.");
754 }
755 }
756 }
757}
758
759/// Returns number of seconds until the next time location streaming for some chat ends
760/// automatically.

Callers 1

startMethod · 0.85

Calls 2

maybe_sendFunction · 0.85
recvMethod · 0.80

Tested by

no test coverage detected