• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 5829059745

pending completion
5829059745

Pull #1844

github

supergi01
added comments for downloader.rs
Pull Request #1844: feat/live-reload, download and start react server

735 of 735 new or added lines in 11 files covered. (100.0%)

45536 of 61287 relevant lines covered (74.3%)

51206.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dozer-cli/src/live/watcher.rs
1
use std::{sync::Arc, time::Duration};
2

3
use crate::shutdown::ShutdownReceiver;
4

5
use super::{state::LiveState, LiveError};
6

7
use dozer_types::{grpc_types::live::LiveResponse, log::info};
8
use notify::{RecursiveMode, Watcher};
9
use notify_debouncer_full::new_debouncer;
10
use tokio::sync::broadcast::Sender;
11

12
pub fn watch(
×
13
    sender: Sender<LiveResponse>,
×
14
    state: Arc<LiveState>,
×
15
    shutdown: ShutdownReceiver,
×
16
) -> Result<(), LiveError> {
×
17
    // setup debouncer
×
18
    let (tx, rx) = std::sync::mpsc::channel();
×
19

20
    let dir: std::path::PathBuf = std::env::current_dir()?;
×
21
    // no specific tickrate, max debounce time 2 seconds
22
    let mut debouncer = new_debouncer(Duration::from_secs(2), None, tx)?;
×
23

24
    debouncer
×
25
        .watcher()
×
26
        .watch(dir.as_path(), RecursiveMode::Recursive)?;
×
27

28
    debouncer
×
29
        .cache()
×
30
        .add_root(dir.as_path(), RecursiveMode::Recursive);
×
31

×
32
    let running = shutdown.get_running_flag().clone();
×
33
    loop {
×
34
        let event = rx.recv_timeout(Duration::from_millis(100));
×
35
        match event {
×
36
            Ok(result) => match result {
×
37
                Ok(_events) => {
×
38
                    build(sender.clone(), state.clone())?;
×
39
                }
40
                Err(errors) => errors.iter().for_each(|error| info!("{error:?}")),
×
41
            },
42
            Err(e) => {
×
43
                if !running.load(std::sync::atomic::Ordering::Relaxed) {
×
44
                    break;
×
45
                }
×
46
                if e == std::sync::mpsc::RecvTimeoutError::Disconnected {
×
47
                    break;
×
48
                }
×
49
            }
50
        }
51
    }
52

53
    Ok(())
×
54
}
×
55

56
pub fn build(sender: Sender<LiveResponse>, state: Arc<LiveState>) -> Result<(), LiveError> {
×
57
    let res = state.build();
×
58

×
59
    match res {
×
60
        Ok(_) => {
61
            let res = state.get_current()?;
×
62
            sender.send(res).unwrap();
×
63
            Ok(())
×
64
        }
65
        Err(e) => Err(e),
×
66
    }
67
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc